Setting the value of a template textbox control in a datagrid

Discussion in 'ASP .Net Web Controls' started by Tim_k, Jun 30, 2004.

  1. Tim_k

    Tim_k Guest

    The code below finds the user entered value in a textbox within a grid. Then it updates the value(s) to the bound datatable. But the value does not display after rebinding to the grid. I think it has something to do with the binding of the textbox? I'm not clear on whether I have to use DATABINDER.EVAL on each template or not.
    Any suggestions?
    Thanks,
    Tim

    For Each dgitem In dgQuery.Items
    txt1 = CType(dgitem.FindControl("txtValues"), TextBox) 'Values textbox
    Session("dtTable1").Rows(dgitem.ItemIndex).Item("txtValues") = txt1
    Next

    drTemp = Session("dtTable1").Rows(rowNum)
    Session("dtTable1").Rows.Remove(drTemp)

    Here's the html for the template textbox in my datagrid:

    <asp:TemplateColumn HeaderText="Values">
    <ItemStyle Wrap="False"></ItemStyle>
    <ItemTemplate>
    <asp:TextBox id="txtValues" runat="server" Width="217px" AutoPostBack="False" ToolTip="Enter Search Value(s)">
    </asp:TextBox>
    Tim_k, Jun 30, 2004
    #1
    1. Advertising

  2. Tim_k

    Tim_k Guest

    I found the answer. Use databinder.eval to bind to the dataitem in my datatable as below.
    asp:TemplateColumn HeaderText="Values">
    <ItemStyle Wrap="False"></ItemStyle>
    <ItemTemplate>
    <asp:TextBox id="txtValues" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"txtValues")%>' Width="217px" AutoPostBack="False" ToolTip="Enter Search Value(s)"></asp:TextBox>


    "Tim_k" wrote:

    > The code below finds the user entered value in a textbox within a grid. Then it updates the value(s) to the bound datatable. But the value does not display after rebinding to the grid. I think it has something to do with the binding of the textbox? I'm not clear on whether I have to use DATABINDER.EVAL on each template or not.
    > Any suggestions?
    > Thanks,
    > Tim
    >
    > For Each dgitem In dgQuery.Items
    > txt1 = CType(dgitem.FindControl("txtValues"), TextBox) 'Values textbox
    > Session("dtTable1").Rows(dgitem.ItemIndex).Item("txtValues") = txt1
    > Next
    >
    > drTemp = Session("dtTable1").Rows(rowNum)
    > Session("dtTable1").Rows.Remove(drTemp)
    >
    > Here's the html for the template textbox in my datagrid:
    >
    > <asp:TemplateColumn HeaderText="Values">
    > <ItemStyle Wrap="False"></ItemStyle>
    > <ItemTemplate>
    > <asp:TextBox id="txtValues" runat="server" Width="217px" AutoPostBack="False" ToolTip="Enter Search Value(s)">
    > </asp:TextBox>
    >
    Tim_k, Jun 30, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. S. Justin Gengo
    Replies:
    0
    Views:
    519
    S. Justin Gengo
    Jul 16, 2003
  2. Luqman
    Replies:
    1
    Views:
    488
    Luqman
    Nov 19, 2006
  3. AGSHAR
    Replies:
    1
    Views:
    591
    AGSHAR
    May 31, 2008
  4. Smith
    Replies:
    1
    Views:
    1,547
    dotNetDave
    Nov 11, 2009
  5. ErwinP
    Replies:
    1
    Views:
    737
    ErwinP
    Aug 19, 2005
Loading...

Share This Page