Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This should be simple but for some reason I am having a fit getting this to work. I have a datagrid with some textbox(s) see sample:

ASP.NET
<Columns>
                           <asp:BoundColumn DataField="ID" HeaderText="ID" ReadOnly="True" Visible="False"> </asp:BoundColumn>
                               <asp:EditCommandColumn HeaderText="Modify" CancelText="Cancel" UpdateText="Update" Visible="true"
                                   ButtonType="LinkButton" EditText="Edit Info">
                                   <ItemStyle Width="5%" HorizontalAlign="Center"></ItemStyle>
                               </asp:EditCommandColumn>
                               <asp:TemplateColumn HeaderText="Last Name" SortExpression="lname">
                                   <ItemStyle Width="150px" HorizontalAlign="Center"></ItemStyle>
                                   <ItemTemplate>
                                       <asp:Label ID="lblLName" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.LName") %>'></asp:Label>
                                   </ItemTemplate>
                                   <EditItemTemplate>
                                       <asp:TextBox ID="tbLNAME" Font-Size="10pt" runat="server"  Text='<%# DataBinder.Eval(Container, "DataItem.LNAME") %>'
                                           Width="150px" MaxLength="30"></asp:TextBox>
                                   </EditItemTemplate>
                                   <FooterTemplate>
                                       <asp:TextBox ID="txtAddLName" Font-Size="10pt" runat="server" Width="150px" MaxLength="30"></asp:TextBox>
                                   </FooterTemplate>
                               </asp:TemplateColumn>
                               <asp:TemplateColumn HeaderText="First Name">
                                   <ItemStyle Width="150px" HorizontalAlign="Center"></ItemStyle>
                                   <ItemTemplate>
                                       <asp:Label ID="lblFName" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.FName") %>'></asp:Label>
                                   </ItemTemplate>
                                   <EditItemTemplate>
                                       <asp:TextBox ID="tbFName" Font-Size="10pt" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.FNAME") %>'
                                           Width="150px" MaxLength="20"></asp:TextBox>
                                   </EditItemTemplate>
                                   <FooterTemplate>
                                       <asp:TextBox ID="txtAddFName" Font-Size="10pt" runat="server" Width="150px" MaxLength="20"></asp:TextBox>
                                   </FooterTemplate>
                               </asp:TemplateColumn>


But when I try to update the information it won't read the new input.
public void dgAccounts_Update(object sender, DataGridCommandEventArgs e)
       {
           //Read in the values of the updated row
           TextBox tbLName = (TextBox)(e.Item.FindControl("tbLNAME"));
           TextBox tbFName = (TextBox)(e.Item.FindControl("tbFNAME"));
           TextBox tbMI = (TextBox)(e.Item.FindControl("tbMI"));
           TextBox tbTitle = (TextBox)(e.Item.FindControl("tbTitle"));
       }


I have never seen this behavior before and don't know how to handle it. Would prefer not to have to create a gridview if it can be avoided as this is a fairly large datagrid.
Posted
Updated 13-Mar-13 9:24am
v3
Comments
[no name] 13-Mar-13 15:29pm    
Okay.... where are you trying to read the input? All you have posted is finding some controls as TextBoxes and that is all.
Jibesh 13-Mar-13 15:51pm    
OP Replied as (moved his comments from solution to here.)

Suffering from cranial/rectal inversion. Had the databind event in the page load event which casused problems.
[no name] 13-Mar-13 17:22pm    
Probably should have left it as a solution if for no other reason that it gets taken off the unanswered list.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900