更新GridView中的文本框 [英] update the textbox in gridview

查看:87
本文介绍了更新GridView中的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我在gridview中实现了一个文本框

如何在gridview中更新该文本框

请帮助我

解决方案

朋友,

您可以以.cs格式使用此行来访问文本框

Control text1 = (TextBox)GridView1.Row[0].Columns[0].FindControl[1];
string strtext = (TextBox)text1.Text;



如果对您有帮助,请接受此答案.

谢谢,
Mahesh Patel


您可以使用for循环遍历网格

TextBox txtBox = new TextBox();

for each (gridview row in gridview.rows)
  {
     txtBox = (TextBox)GridView1.Row[row.rowindex].Columns[0].FindControl[1];
     string strtext = (TextBox)txtBox.Text;
  }



问候
koolprasad2003




如何在gridview中获取TextBox控件的值.我写一些小代码.希望对你有帮助.

在html页面中:

<pre lang="xml"><asp:GridView runat=server ID=GridView1  CellPadding=3 CellSpacing=0 AutoGenerateColumns=false>
  <Columns>
   <asp:TemplateField HeaderText="Column1">
     <ItemTemplate>
     <asp:TextBox runat=server ID=TextBox1 Width=250px />
     </ItemTemplate>
   </asp:TemplateField>
  <asp:BoundField DataField="Column1" HeaderText="Column1" />
     <asp:BoundField DataField="Column2" HeaderText="Column2" />
     <asp:BoundField DataField="Column3" HeaderText="Column3" />
  </Columns>
  </asp:GridView>



在代码页中:

private void Update()
{
   foreach (GridViewRow GridViewRow1 in this.GridView1.Rows)
            {
                TextBox tb = (TextBox)GridViewRow1.FindControl("TextBox1");
                //if have control name ''TextBox1''
                if (tb != null)
                {
                    //get textbox control''s value of each row in gridview
                   string value = tb.Text;
                }
            }
}


hi i implemented a textbox in gridview

how can i update that textbox in gridview

plese help me

解决方案

hi friend,

You can use this line in .cs form for access the textbox

Control text1 = (TextBox)GridView1.Row[0].Columns[0].FindControl[1];
string strtext = (TextBox)text1.Text;



Accept this answer if it is helpful to you.

Thanks,
Mahesh Patel


you can use for loop to traverse the grid

TextBox txtBox = new TextBox();

for each (gridview row in gridview.rows)
  {
     txtBox = (TextBox)GridView1.Row[row.rowindex].Columns[0].FindControl[1];
     string strtext = (TextBox)txtBox.Text;
  }



regards
koolprasad2003


hi,

how to get TextBox control''s value in gridview. I write some small codes. Hope help u.

In html Page:

<pre lang="xml"><asp:GridView runat=server ID=GridView1  CellPadding=3 CellSpacing=0 AutoGenerateColumns=false>
  <Columns>
   <asp:TemplateField HeaderText="Column1">
     <ItemTemplate>
     <asp:TextBox runat=server ID=TextBox1 Width=250px />
     </ItemTemplate>
   </asp:TemplateField>
  <asp:BoundField DataField="Column1" HeaderText="Column1" />
     <asp:BoundField DataField="Column2" HeaderText="Column2" />
     <asp:BoundField DataField="Column3" HeaderText="Column3" />
  </Columns>
  </asp:GridView>



In code page:

private void Update()
{
   foreach (GridViewRow GridViewRow1 in this.GridView1.Rows)
            {
                TextBox tb = (TextBox)GridViewRow1.FindControl("TextBox1");
                //if have control name ''TextBox1''
                if (tb != null)
                {
                    //get textbox control''s value of each row in gridview
                   string value = tb.Text;
                }
            }
}


这篇关于更新GridView中的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆