无法在网格视图中找到行索引 [英] unable to find row index ..in grid view

查看:88
本文介绍了无法在网格视图中找到行索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好bros ....

i有一个网格视图..



按钮点击我要输入一些行数据其中r通过复选框检查..



为此我写代码...

hello bros....
i have a grid view..

on button click i want to enter some data of lines which r checked by check box..

for this i write the code...

string str;
    protected void Button2_Click(object sender, EventArgs e)
    {
        


        
        foreach (GridViewRow gvr in GridView1.Rows)
        {
              int rrowindx= gvr.RowIndex;
            CheckBox cbb = (CheckBox)GridView1.Rows[rrowindx].Cells[6].Controls[1];
            TextBox txt = (TextBox)GridView1.Rows[rrowindx].Cells[6].Controls[2];


==============================================================================
             str= GridView1.Rows[rrowindx].Cells[0].Text.ToString();
              //this 'str ' not returning any value.
==============================================================================

            if(cbb.Checked)
            {
            SqlConnection con = new SqlConnection("Data Source=GAURAV-PC\\SQLEXPRESS;Initial Catalog=mydatabase;Integrated Security=True");
            cmd = con.CreateCommand();
            cmd.CommandText = "execute this @Eid,@txtvalue";
            cmd.Parameters.Add("@Eid", SqlDbType.Int).Value = str;
            cmd.Parameters.Add("@txtvalue", SqlDbType.VarChar).Value = txt.Text;

            

        }}
    }





**** ****没有值进入str ..这是ma问题



******** there is no value coming in str..this is ma problem

推荐答案

看看如何形成这些......

http://forums.asp.net/t/1805804 .aspx / 1?怎么+ + + + + + RowView + + + Gridview + [ ^ ]

http://www.c-sharpcorner.com/Forums/Thread/44214/ [ ^ ]

http://weblogs.asp.net/gurusarkar/archive/2010/09/22/get-gridview-rowindex-upon-button- click.aspx [ ^ ]
See how to do it form these..
http://forums.asp.net/t/1805804.aspx/1?How+to+get+RowIndex+of+Gridview+[^]
http://www.c-sharpcorner.com/Forums/Thread/44214/[^]
http://weblogs.asp.net/gurusarkar/archive/2010/09/22/get-gridview-rowindex-upon-button-click.aspx[^]


foreach (GridViewRow gvr in GridView1.Rows)
                {
                    CheckBox cbb = (CheckBox)gvr.Cells[6].Controls[1];
                    if (cbb.Checked)
                    {
                        TextBox txt = (TextBox)gvr.Cells[6].Controls[2];
                        string str = ((System.Web.UI.DataBoundLiteralControl)(gvr.Cells[0].Controls[0])).Text;
                        SqlConnection con = new SqlConnection("Data Source=GAURAV-PC\\SQLEXPRESS;Initial Catalog=mydatabase;Integrated Security=True");
                        SqlCommand cmd = con.CreateCommand();
                        cmd.CommandText = "execute this @Eid,@txtvalue";
                        cmd.Parameters.Add("@Eid", SqlDbType.Int).Value = str;
                        cmd.Parameters.Add("@txtvalue", SqlDbType.VarChar).Value = txt.Text;
                    }
                }


这篇关于无法在网格视图中找到行索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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