Professional Web Applications Themes

Get textbox value from datagrid problem - ASP.NET Data Grid Control

Hi, could you please tell me what is wrong with this piece of code. I have a DataGrid, and I would like to know the value of a textbox field, and it never returns anything. textbox is in item template. <asp:TemplateColumn HeaderText="Value"> <ItemTemplate> <asp:TextBox id="txtInput" runat="server"></asp:TextBox> </ItemTemplate> </asp:TemplateColumn> Dim item As DataGridItem If Not IsPostBack Then For Each item In DataGrid1.Items Dim tb As TextBox = CType(item.FindControl("txtInput"), TextBox) ListBox1.Items.Add(tb.Text) Next End If Thank you. Steve...

  1. #1

    Default Get textbox value from datagrid problem

    Hi, could you please tell me what is wrong with this piece of code.
    I have a DataGrid, and I would like to know the value of a textbox field,
    and it never returns anything.
    textbox is in item template.

    <asp:TemplateColumn HeaderText="Value">
    <ItemTemplate>
    <asp:TextBox id="txtInput" runat="server"></asp:TextBox>
    </ItemTemplate>
    </asp:TemplateColumn>

    Dim item As DataGridItem
    If Not IsPostBack Then

    For Each item In DataGrid1.Items
    Dim tb As TextBox = CType(item.FindControl("txtInput"),
    TextBox)
    ListBox1.Items.Add(tb.Text)
    Next
    End If


    Thank you.
    Steve


    Steve F. Guest

  2. #2

    Default Re: Get textbox value from datagrid problem

    Hi,

    the following code has been create in the C#. You will be able to translate
    to the VB.Net

    C#
    TextBox txt = ((TextBox)item.Columns[0].Controls[0]);

    VB:
    Dim tb As TextBox = CType(item.Columns(0).Controls(1))

    Right now you know how you can get a value from a textbox.

    bye


    "Steve F." <sfflintind.com> wrote in message
    news:%23lDCCUPkEHA.1712TK2MSFTNGP09.phx.gbl...
    > Hi, could you please tell me what is wrong with this piece of code.
    > I have a DataGrid, and I would like to know the value of a textbox field,
    > and it never returns anything.
    > textbox is in item template.
    >
    > <asp:TemplateColumn HeaderText="Value">
    > <ItemTemplate>
    > <asp:TextBox id="txtInput" runat="server"></asp:TextBox>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    >
    > Dim item As DataGridItem
    > If Not IsPostBack Then
    >
    > For Each item In DataGrid1.Items
    > Dim tb As TextBox = CType(item.FindControl("txtInput"),
    > TextBox)
    > ListBox1.Items.Add(tb.Text)
    > Next
    > End If
    >
    >
    > Thank you.
    > Steve
    >
    >

    Michael Tkachev Guest

  3. #3

    Default Re: Get textbox value from datagrid problem

    foreach(DataGridItem i in teklifformu.Items)
    {
    Dim tb As TextBox = CType(i.Cells[YourTexboxInWhichCloumn].FindControl("fiyat")));
    }
    deneme Guest

Similar Threads

  1. DataGrid ItemStyle is a textbox and doesn't update the datagrid datasource
    By matthew schouppe in forum ASP.NET Data Grid Control
    Replies: 3
    Last Post: April 30th, 03:02 PM
  2. How do I add a Textbox to my DataGrid?
    By B Holt in forum ASP.NET Data Grid Control
    Replies: 2
    Last Post: October 31st, 03:56 AM
  3. Custom TextBox in a DataGrid
    By Rubén Ruiz in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: October 16th, 03:38 PM
  4. Datagrid with textbox
    By Saravana in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: September 4th, 01:53 PM
  5. textbox in datagrid
    By Noel Hoo in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: September 3rd, 05:27 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139