I am very new to .Net and have recently taken over someone else’s project. I am developing an asp webpage using C#.
I have an asp:table that is populated using data from a database. However, there is also a column that contains checkboxes and a column that contains text boxes like so:
Location | Stock | Issue (checkbox column) | Issued (textbox column)
I want the user to click a checkbox and the value of the ‘Stock’ column for that row is then entered into the textbox of that row.
I have already populated the table with data and the user controls, I am only struggling with the event.
My code is shown below:
Expand|Select|Wrap|Line Numbers
- TableRow row = new TableRow();
- TableCell cellLoc = new TableCell();
- TableCell cellStock = new TableCell();
- TableCell cellIss = new TableCell();
- TableCell cellIssued = new TableCell();
- cellLoc.Width = Unit.Pixel(75);
- cellStock.Width = Unit.Pixel(75);
- cellIss.Width = Unit.Pixel(75);
- cellIssued.Width = Unit.Pixel(75);
- TextBox txtIssued = new TextBox();
- CheckBox issue = new CheckBox();
- cellLoc.HorizontalAlign = HorizontalAlign.Left;
- cellLoc.Text = location.Aisle + " " + location.Bay + " " + location.Level;
- if (matReq.Status >= MaterialRequisitionStatus.Picking)
- {
- cellStock.Text = location.QtyRequired.ToString();
- if (matReq.Status == MaterialRequisitionStatus.Picking)
- {
- if (userCanUpdate_)
- {
- issue.ID = "cbIssue_" + location.ProductCode + "_" + n.ToString();
- string box = issue.ID;
- issue.AutoPostBack = true;
- cellIss.Controls.Add(issue);
- txtIssued.Width = Unit.Pixel(50);
- txtIssued.ID = "txtIssued_" + location.ProductCode + "_" + n.ToString();
- txtIssued.Style.Add("text-align", "right");
- cellIssued.Controls.Add(txtIssued);
- }
- else
- cellIssued.Text = "-";
- }
- else
- cellIssued.Text = location.QtyPicked.ToString();
- }
- else
- {
- cellStock.Text = location.Stock.ToString();
- cellIssued.Text = "-";
- }
- row.Cells.Add(cellLoc);
- row.Cells.Add(cellStock);
- row.Cells.Add(cellIss);
- row.Cells.Add(cellIssued);
- tblStock.Rows.Add(row);
Thanks in advance,
Jonathan.