本文介绍了如何在图像按钮单击事件上的网格视图中获取不可见的列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有id = gv的网格视图,该视图在运行时绑定...
我也使第一列不可见..
现在在图像按钮上单击,我想用该不可见列值更新数据..但我无法获取该不可见列值...
请给我一些想法,我错了.
这是我的图像按钮单击事件代码..

i have grid view with id=gv which binds at runtime ...
also i make first column invisible..
now on image button click i want to update data with that invisible column value..but i cant get that invisible column value...
plz give some idea where i m wrong..
here is my code on image button click event..

protected void imgbtnDelete_Click(object sender, ImageClickEventArgs e)
    {
        string strcon = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
        SqlConnection conn = new SqlConnection(strcon);
        
        GridViewRow selectedRow = ((Control)sender).Parent.NamingContainer as GridViewRow;

        gv.SelectedIndex = selectedRow.RowIndex;
        string id = selectedRow.Cells[1].Text;
       
        string qry = "update dbo.[user] set isDeleted='false' where userId='" + ID + "'";
        SqlCommand cmd = new SqlCommand(qry, conn);
        conn.Open();
        int r = cmd.ExecuteNonQuery();
        if (r > 0)
        {
            Response.Redirect("editUser.aspx");

        }
        conn.Close();
    }

推荐答案


这篇关于如何在图像按钮单击事件上的网格视图中获取不可见的列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 14:13