Note that there are some explanatory texts on larger screens.

plurals
  1. POasp:GridView doesn't contain control added in OnRowDataBound
    primarykey
    data
    text
    <p>I have problem, I can't get control which I added in DataGrid. I am adding it in OnRowDataBound event like:</p> <pre><code>protected void RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowState == DataControlRowState.Edit || e.Row.RowState == (DataControlRowState.Alternate | DataControlRowState.Edit)) { //int cindex = 0; //for (cindex = 0; cindex &lt; e.Row.Controls.Count; cindex++) foreach (Control ctl in e.Row.Controls) { DataControlFieldCell dcctl = (DataControlFieldCell)ctl; TableCell tcell = (TableCell)dcctl; Label lblComment = new Label(); TextBox txtComment = new TextBox(); lblComment.Text = "&lt;br&gt;Comment: "; dcctl.Controls.Add(lblComment); dcctl.Controls.Add(txtComment); //tcell.Controls.Add(lblComment); //tcell.Controls.Add(txtComment); //e.Row.Cells[cindex].Controls.Add(lblComment); //e.Row.Cells[cindex].Controls.Add(txtComment); </code></pre> <p>What is happening here: there is already exist one TextBox in TableCell by default and I want to add another one TextBox and Label. After the bounding I can see 2 textboxes, I can input data into the both, but when I click Update button, then raises <code>OnRowUpdating</code> event where I can't get my TextBox!</p> <pre><code>protected void RowUpdating(object sender, GridViewUpdateEventArgs e) { grdView.EditIndex = -1; int counter = 0; for (counter = 0; counter &lt; grdView.Rows[e.RowIndex].Cells.Count; counter++) { foreach (Control ctl in grdView.Rows[e.RowIndex].Cells[counter].Controls) { </code></pre> <p>And here I will be getting only default one TextBox (with its value). But my TextBox is disappeared! :(</p> <p>What could you suggest me here to do?</p> <p>P.S. I can't use predifined columns, like <code>asp:TemplateField</code> in aspx file, because my table has different amount of rows every time. It is dynamic </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload