当前位置:编程学习 > C#/ASP.NET >>

在有多列数据的gridview中如何通过点击里面的linkbutton,读取到对应的序号列(超链接)的值,再使用该值修改数据库的值

如题,请各位大侠帮帮忙 --------------------编程问答-------------------- 在绑定事件里面进行就可以了,e.Row.FindControl可以找到任何控件 --------------------编程问答-------------------- 这个网上很多,搜搜就可以 --------------------编程问答--------------------         private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if(e.ColumnIndex==2)        //判断是否为LinkButton列
                {
                    foreach(DataGridViewRow dgr in dataGridView1.Rows)
                    {
                        DataGridViewLinkCell cell = (DataGridViewLinkCell)dgr.Cells[2];
                        object val = cell.FormattedValue;         //获取连接值

                         //这里进行你的数据库操作
                         。。。。。。。。。。。
                    }
                    
                }
            }
            catch(Exception ex)
            {

            }
        }
    }
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,