Results 1 to 2 of 2

Thread: submit inputs from GridView Textbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2008
    Posts
    182

    submit inputs from GridView Textbox

    I want to gather inputs from Gridview textboxes and update the database with the inputs. I can't simply write a get() method to retrieve textbox inputs in this case. Can you shed me some light on how to get start with this? Thanks.

    Code:
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
                    AutoGenerateColumns="False" Font-Names="Verdana" Font-Size="9pt" OnPageIndexChanging="GridView1_PageIndexChanging"
                    OnSelectedIndexChanged="GridView1_SelectedIndexChanged" 
                    OnRowDataBound="GridView1_RowDataBound" OnSorting="GridView1_Sorting" 
                    PageSize="5">
                    <Columns>
                        <asp:TemplateField HeaderText="ID" SortExpression="ID">
                            <ItemTemplate>
                                <asp:Label ID="ID" runat="server" Text='<%# Eval("ID") %>' Width="80px"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="LastName" SortExpression="LastName">
                            <ItemTemplate>
                                <asp:Label ID="LastName" runat="server" Text='<%# Eval("LastName") %>' Width="80px"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="FirstName" SortExpression="FirstName">
                            <ItemTemplate>
                                <asp:Label ID="FirstName" runat="server" Text='<%# Eval("FirstName") %>' Width="80px"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="UserInput" SortExpression="UserInput">
                            <ItemTemplate>
                                <asp:TextBox ID="UserInput" runat="server" Text='<%# Eval("UserInput") %>'
                                    Width="80px"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>

  2. #2
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: submit inputs from GridView Textbox

    Assuming you have a button outside of the GridView that should do all of the submitting... in the click event of that button, loop through every DataRow in the GridView and pull out the text box, doing whatever you need to with its' value.

Posting Permissions

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



Click Here to Expand Forum to Full Width