获取gridview中的文本框值 [英] get text box value inside gridview

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

问题描述

我已将GridView1放在.aspx文件的面板中。这是我的代码。

I have placed GridView1 inside a panel in .aspx file.Here is my code behind.

foreach (GridViewRow gvrC in GridView1.Rows)
        {
            if (gvrC.Visible)
            {
                for (int x = 2; x < GridView1.Columns.Count; x++)
                {
                    foreach (Control cc in gvrC.Cells[x].Controls)
                    {
                        string str = ((TextBox)cc).Text;
                        //my code here. I want to display textbox value
                    }
                }
            }
        }



但它没有输入第二个foreach()loop.plz给我解决方案。

谢谢。


but it is not entering the 2nd foreach() loop.plz give me the solution.
Thank You.

推荐答案

请尝试以下代码。您不必担心放置文本框的列。 -



Try the below codes. You don't have to worry about on which column you have put the text boxes. -

foreach (GridViewRow gvrC in GridView1.Rows)
        {
                        string str = ((TextBox)gvrC .FindControl("txtCC")).Text;

                        //my code here. I want to display textbox value
        }


好的,请尝试如下...

Okay try like below...
foreach(GridViewRow gvrC in GridView1.Rows)
{
    if (gvrC.Visible)
    {
        for(int i = 2; i < GridView1.Columns.Count, i++)
        {
            String str = row.Cells[i].Text;
        }
    }
}


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

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