本文介绍了行数据绑定事件不会发生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用行数据绑定,在其中我使用查询复选框值并获取vakue来检查复选框的真假.

但是没有用..

请帮助我,,
在此先感谢.....



i am using row databound in which i used query for checkbox value and get the vakue for checking checkbox for true or false.

but did not workk..

Please Help Me,,,
Thanks in advance.....



protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //{
            //    CheckBox chk = (CheckBox)e.Row.Cells[2].FindControl("CheckBox1");
            //    if (chk == null)
            //    {
            //        if (e.Row.Cells[1].Text =="1") //check for status column
            //            chk.Checked = true;
            //    }
            //}

            int i = 1;
            string s11 = "Select bit_indicator,category,sub_cat from document_rights where user_id='" + drop_user.SelectedItem.Value + "' and bit_indicator='" + i + "' and category='" + drop_cat.SelectedItem.Value + "' and sub_cat='" + drop_sub_cat.SelectedItem.Value + "'";
            SqlDataAdapter ad2 = new SqlDataAdapter(s11, c.getcon());
            DataSet ds2 = new DataSet();
            ad2.Fill(ds2);
            if (ds2.Tables[0].Rows.Count != 0)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    CheckBox chk = (CheckBox)e.Row.Cells[2].FindControl("CheckBox1");
                    if (chk == null)
                    {
                        if (e.Row.Cells[1].Text == "1") //check for status column
                            chk.Checked = true;
                    }

                }
            }
            else
            {

            }
        }
    }

推荐答案


这篇关于行数据绑定事件不会发生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 13:08