A
Amadelle
Hi all and thanks in advance for your help,
I have a problem with capturing the changed value of a text box in a
datagrid. The datagrid is populated based on a dataset and I am using
template columns to show some of the columns. Few of the columns have
textboxes to make them available for editing. I am trying to update the
dataset all at once using one update button. Here is my code... (for
simplicity I have only listed one of the columns)
============================================================================
===
For the ASP.NET columns:
<asp:datagrid id="dgGED" runat="server" AutoGenerateColumns="False"
ItemStyle-BackColor="#E8E8E8"
HeaderStyle-BackColor="#D0D0D0" font-size="10pt" font-names="Arial"
gridlines="vertical"
Bordercolor="black">
<Columns>
<asp:TemplateColumn>
<HeaderTemplate>
<B>EmpNumber</B>
</HeaderTemplate>
<ItemTemplate>
<center>
<asp:TextBox ID="txtEmpNum" Runat=server text='<%#
DataBinder.Eval(Container.DataItem, "EmpNumber") %>' size=5 style="border=0"</asp:TextBox></center>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
============================================================================
===
The code behind C#:
//Iterate and apply changes.
string strEmpNumber = "";
foreach (DataGridItem item in dgGED.Items)
{
//Get value from grid.
strEmpNumber = (string)((TextBox) item.FindControl("txtEmpNum")).Text;
ds.Tables[0].Rows[item.ItemIndex]["EmpNumber"] = strEmpNumber;
}
============================================================================
===
Just a few more notes: If I change the value of the textbox to some new
text, the strEmpNumber still shows the old value of the textbox before
editing (basically the original value that comes from the dataset). I don't
get any errors and everything seems to run just fine. So I don't know what
I am missing that the new change is not captured in the
strEmpNumber = (string)((TextBox) item.FindControl("txtEmpNum")).Text;
statement?
Any help and suggestions are truely appreciated,
Thanks a bunch,
Amadelle
I have a problem with capturing the changed value of a text box in a
datagrid. The datagrid is populated based on a dataset and I am using
template columns to show some of the columns. Few of the columns have
textboxes to make them available for editing. I am trying to update the
dataset all at once using one update button. Here is my code... (for
simplicity I have only listed one of the columns)
============================================================================
===
For the ASP.NET columns:
<asp:datagrid id="dgGED" runat="server" AutoGenerateColumns="False"
ItemStyle-BackColor="#E8E8E8"
HeaderStyle-BackColor="#D0D0D0" font-size="10pt" font-names="Arial"
gridlines="vertical"
Bordercolor="black">
<Columns>
<asp:TemplateColumn>
<HeaderTemplate>
<B>EmpNumber</B>
</HeaderTemplate>
<ItemTemplate>
<center>
<asp:TextBox ID="txtEmpNum" Runat=server text='<%#
DataBinder.Eval(Container.DataItem, "EmpNumber") %>' size=5 style="border=0"</asp:TextBox></center>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
============================================================================
===
The code behind C#:
//Iterate and apply changes.
string strEmpNumber = "";
foreach (DataGridItem item in dgGED.Items)
{
//Get value from grid.
strEmpNumber = (string)((TextBox) item.FindControl("txtEmpNum")).Text;
ds.Tables[0].Rows[item.ItemIndex]["EmpNumber"] = strEmpNumber;
}
============================================================================
===
Just a few more notes: If I change the value of the textbox to some new
text, the strEmpNumber still shows the old value of the textbox before
editing (basically the original value that comes from the dataset). I don't
get any errors and everything seems to run just fine. So I don't know what
I am missing that the new change is not captured in the
strEmpNumber = (string)((TextBox) item.FindControl("txtEmpNum")).Text;
statement?
Any help and suggestions are truely appreciated,
Thanks a bunch,
Amadelle