Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / November 2006

Tip: Looking for answers? Try searching our database.

GridView does not show updated Records

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg - 25 Oct 2006 19:56 GMT
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.
Ken Cox [Microsoft MVP] - 26 Oct 2006 02:42 GMT
Hi Greg,

You haven't shown us the complete code behind so I can't tell much.

However, the first thing I wonder is whether you are inadvertently rebinding
to the original data on each postback?

Ken
Microsoft MVP [ASP.NET]
Nipissing Township, Ontario, Canada

> Hi,
>
[quoted text clipped - 96 lines]
>
> Thanks in advance.
Tom Biggar - 06 Nov 2006 18:28 GMT
Greg,
did you ever get an answer to this problem?  I am fighting the same
thing.  I see lots of people with the question but, so far, no answers.
If you have a solution, please share it, and I will let you know if I
find something.
Tom
pblack9455 - 26 Nov 2006 19:49 GMT
Any solutions to this simple first use case?   I've tried ObjectDataSource,
but I need to bind to an ArrayList of Objects... the ArraList should
initially be empty then allow me to populate it before the final 'accept'
which then writes the ArrayList to the database.... I've been looking at this
for what feels like days!

> Greg,
> did you ever get an answer to this problem?  I am fighting the same
[quoted text clipped - 4 lines]
>
> *** Sent via Developersdex http://www.developersdex.com ***

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.