G
Greg
Hi,
This should be dirt simple... but clearly I am missing something. I
have a GridView on an ASP Page. There are 5 fields on the page (2 of
which can be updated), the user clicks edit, they go into edit mode,
the user changes the data clicks updated... their old data is still
there... I run some debug assertions and when I try and grab the value
of the text fields I see the old values (not what is currenly in the
textbox on the screen).
I'm stumped... any ideas I am open to them.
Greg
Code (asp page)
<asp:GridView ID="StatusGrid" runat="server" CellPadding="1"
ForeColor="#333333" Width="100%" AllowSorting="True"
OnRowCommand="StatusGrid_RowCommand" AutoGenerateColumns="False"
OnRowEditing="StatusGrid_RowEditing"
OnRowCreated="StatusGrid_RowCreated"
OnRowDeleting="StatusGrid_RowDeleting"
OnRowUpdating="StatusGrid_RowUpdating">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="LightGray" ForeColor="#333333"
HorizontalAlign="Center" Wrap="False" />
<EditRowStyle BackColor="#999999" Font-Size="Medium" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="ScrollBar" Font-Size="X-Small" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775"
/>
<Columns>
<asp:BoundField DataField="sts_id" HeaderText="sts_id"
ReadOnly="True" SortExpression="sts_id">
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:TemplateField HeaderText="sts_code">
<ItemTemplate>
<%# Eval("sts_code")%>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle HorizontalAlign="Left" />
<EditItemTemplate>
<asp:textbox id="sts_code"
text='<%#Eval("sts_code")%>'
width="50"
runat="server"/>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="sts_description">
<ItemTemplate>
<%# Eval("sts_description")%>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle HorizontalAlign="Left" />
<EditItemTemplate>
<asp:textbox id="sts_description"
text='<%#Eval("sts_description")%>'
width="200"
runat="server"/>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="sts_date_created"
HeaderText="sts_date_created" SortExpression="sts_date_created"
ReadOnly="True" />
<asp:BoundField DataField="sts_date_modified"
HeaderText="sts_date_modified" SortExpression="sts_date_modified"
ReadOnly="True"/>
<asp:CommandField ButtonType="Button" ShowDeleteButton="True"
ShowEditButton="True" CausesValidation="False" InsertVisible="False" />
</Columns>
</asp:GridView>
Code-Behind
protected void StatusGrid_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{
GridViewRow row = StatusGrid.Rows[StatusGrid.EditIndex];
TextBox Code = row.FindControl("sts_code") as TextBox;
TextBox Description = row.FindControl("sts_description") as
TextBox;
e.NewValues["sts_code"] = Code.Text;
e.NewValues["sts_description"] = Description.Text;
}
The Code.Text and Description.Text fields both have their old
values????
Thanks in advance.
This should be dirt simple... but clearly I am missing something. I
have a GridView on an ASP Page. There are 5 fields on the page (2 of
which can be updated), the user clicks edit, they go into edit mode,
the user changes the data clicks updated... their old data is still
there... I run some debug assertions and when I try and grab the value
of the text fields I see the old values (not what is currenly in the
textbox on the screen).
I'm stumped... any ideas I am open to them.
Greg
Code (asp page)
<asp:GridView ID="StatusGrid" runat="server" CellPadding="1"
ForeColor="#333333" Width="100%" AllowSorting="True"
OnRowCommand="StatusGrid_RowCommand" AutoGenerateColumns="False"
OnRowEditing="StatusGrid_RowEditing"
OnRowCreated="StatusGrid_RowCreated"
OnRowDeleting="StatusGrid_RowDeleting"
OnRowUpdating="StatusGrid_RowUpdating">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="LightGray" ForeColor="#333333"
HorizontalAlign="Center" Wrap="False" />
<EditRowStyle BackColor="#999999" Font-Size="Medium" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="ScrollBar" Font-Size="X-Small" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775"
/>
<Columns>
<asp:BoundField DataField="sts_id" HeaderText="sts_id"
ReadOnly="True" SortExpression="sts_id">
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:TemplateField HeaderText="sts_code">
<ItemTemplate>
<%# Eval("sts_code")%>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle HorizontalAlign="Left" />
<EditItemTemplate>
<asp:textbox id="sts_code"
text='<%#Eval("sts_code")%>'
width="50"
runat="server"/>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="sts_description">
<ItemTemplate>
<%# Eval("sts_description")%>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle HorizontalAlign="Left" />
<EditItemTemplate>
<asp:textbox id="sts_description"
text='<%#Eval("sts_description")%>'
width="200"
runat="server"/>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="sts_date_created"
HeaderText="sts_date_created" SortExpression="sts_date_created"
ReadOnly="True" />
<asp:BoundField DataField="sts_date_modified"
HeaderText="sts_date_modified" SortExpression="sts_date_modified"
ReadOnly="True"/>
<asp:CommandField ButtonType="Button" ShowDeleteButton="True"
ShowEditButton="True" CausesValidation="False" InsertVisible="False" />
</Columns>
</asp:GridView>
Code-Behind
protected void StatusGrid_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{
GridViewRow row = StatusGrid.Rows[StatusGrid.EditIndex];
TextBox Code = row.FindControl("sts_code") as TextBox;
TextBox Description = row.FindControl("sts_description") as
TextBox;
e.NewValues["sts_code"] = Code.Text;
e.NewValues["sts_description"] = Description.Text;
}
The Code.Text and Description.Text fields both have their old
values????
Thanks in advance.