Basically I want tO retrieve a “TextBox1” which I add in to one of the new column (TemplateField) of the gridview and the rest of the column are data load from the sqldatasource control
i will want to indicate the “TextBox1” basic value that i calculated…so the result is when the default.aspx is loaded (which mean page load) the “TextBox1″ should have show the calculated value…sO now is how am I going to retrieve that ” TextBox1″ from the gridview in order for me to indicate a value
cause i dont need to use this code below as my gridview data is use the retrieve in sqldatasource in the design default.aspx
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("Age");
DataRow dr = dt.NewRow();
dr["Name"] = "Chris Harris";
dr["Age"] = "40";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["Name"] = "Sean Williams";
dr["Age"] = "39";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["Name"] = "Paul Newcombe";
dr["Age"] = "38";
dt.Rows.Add(dr);
GridView1.DataSource = dt;
GridView1.DataBind();
SO how should do to retrieve that ” TextBox1″ from the gridview in order for me to indicate a value
<ItemTemplate>
<table style="width: 73%; height: 31px;">
<tr>
<td class="style1">
<asp:Label ID="Label2" runat="server" Text="Calculation:"></asp:Label>
</td>
<td >
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
</table>
</ItemTemplate>
If this a row-by-row situation, you will probably want to do this in the
RowDataBoundevent on the GridView: