c#获取gridview的值代码分享

GridView设置如下:

复制代码 代码如下:

                EmptyDataText="暂时没有记录!" Width="100%"  Height="100%" AllowPaging="True" OnPageIndexChanging="GridViewlb_PageIndexChanging"
                DataKeyNames="id" PageSize="26" OnRowCreated="GridViewlb_RowCreated" OnRowDataBound="GridViewlb_RowDataBound"
                AllowSorting="True">

              
                    
                    
                    
                    
                          
                          
                    

                    
                    
                    
                          
                                 
                          

                        
                    
                  
              

获得GridView中TextBox的值:

显然这里是模板列,可以利用:

复制代码 代码如下:

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

如果不是模板列,可以利用

复制代码 代码如下:

string str = this.GridView1.Rows[行号].Cells[6].Text.Trim();

你可能感兴趣的:(c#获取gridview的值代码分享)