c gets the gridview value code share

  • 2020-05-26 10:00:57
  • OfStack

GridView Settings are as follows:


<asp:GridView ID="GridViewlb" runat="server" AutoGenerateColumns="False" CssClass="tabblue" ShowCellToolTip=" True"
                EmptyDataText=" No record yet! " Width="100%"  Height="100%" AllowPaging="True" OnPageIndexChanging="GridViewlb_PageIndexChanging"
                DataKeyNames="id" PageSize="26" OnRowCreated="GridViewlb_RowCreated" OnRowDataBound="GridViewlb_RowDataBound"
                AllowSorting="True">

              <Columns  >
                    <asp:BoundField DataField="id" HeaderText=" Serial number "  />
                    <asp:BoundField DataField="type" HeaderText=" type " />
                    <asp:BoundField DataField="item" HeaderText=" project " ></asp:BoundField>
                    <asp:BoundField DataField="detail" HeaderText=" content " >
                          <ItemStyle Width="100px" />
                          <ItemStyle Width="120px" />
                    </asp:BoundField>
                    <asp:BoundField DataField="basescore" HeaderText=" The basic points " />
                    <asp:BoundField DataField="stdevaluation" HeaderText=" Scoring criteria " />
                    <asp:TemplateField HeaderText=" score " >
                          <ItemTemplate> 
                                <asp:TextBox  id="textbox1" runat="server" Text="" Width="80%" Height="24px"></asp:TextBox>  
                          </ItemTemplate>
                        <ItemStyle Width="50px" />
                    </asp:TemplateField>                   
              </Columns>
</asp:GridView>

Get the value of TextBox in GridView:

Obviously here is the template column, which can be used:


string str = ((TextBox)(this.GridView1.Rows[ The line Numbers ].Cells[6].FindControl("textBox1"))).Text.Trim();

If it is not a template column, it can be used


string str = this.GridView1.Rows[ The line Numbers ].Cells[6].Text.Trim();


Related articles: