King wilkinson
New Member
Having trouble updating a database using a datagrid and EditItemTemplate. The problem lies not in the connection to the database in any way, the sql is working fine. Nor do I get any errormessages, but what happens is that what is written in the textboxes that appear after choosing Edit, is never used. Instead the defaulttext used, which I read in from the database and put in the textboxes.<BR><BR>Here's a snippet from users.aspx:<BR><BR><Columns><BR> <asp:TemplateColumn HeaderText="Users" HeaderStyle-Width="160"><BR> <ItemTemplate><BR> <asp:Label ID=lblUser Runat=server text='<%# Container.DataItem("admin") %>' /><BR> </ItemTemplate><BR> <EditItemTemplate><BR> <asp:TextBox ID=txtUser Runat=server Text='<%# container.dataitem("admin") %>' Width=80 /><BR> </EditItemTemplate><BR><BR>So when Edit is clicked, a textbox appears, and a value is written to it, being the defaulttext mentioned above. (It dosen't matter if I write anything to it, dosen't work with blank either)<BR><BR>At this point I alter the textbox, and click Update. Snippet from users.vb:<BR><BR>Dim tUser As TextBox = E.Item.FindControl("txtUser")<BR>response.write(tUser.text)<BR><BR>What appears on my screen now is the text read from the database above with "Text='<%# container.dataitem("admin") %>'", and not the text that I wrote in instead.<BR><BR>Thus, when trying to update the database, it updates with the old values, alas not updating at all. The rest works as it should, cancel and delete that is. And here's the tricky part:<BR><BR>It all worked GREAT yesterday!! And the code has not been altered! Is there any other parameters that can have been changed to mess me up? Or is the code simply faulty? I'm confused out of my mind, and can't figure out where to go next...<BR><BR>Thankful for all input,<BR><BR>MagnusAre you rebinding the DataGrid BEFORE doing your updates ??? That is usually the explanation for this behavior in my experience. You may want to post more code for a better answer.<BR><BR>regards,<BR><BR>Dave Kawliche<BR>http://AccessHelp.net<BR>http://1ClickDB.com