如何在网格视图中检索数据

如何在网格视图中检索数据

本文介绍了如何在网格视图中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我没有获取griedview中的数据,能否给我解决我的问题的方法?


i am not getting how to retrive the data in griedview can you give me the solution of my problem

推荐答案


protected void uxRoleCheckBoxSelector_CheckChanged(object sender, EventArgs e)
        {
            // Cast sender to CheckBox
            CheckBox activeCheckBox = (CheckBox)sender;
            // Retrieve the row where CheckBox is contained (NamingContainer used to retrive parent control
            GridViewRow row = (GridViewRow)activeCheckBox.NamingContainer;
            // Retrive the Lable for an User name in a row
            Label myUserName = (Label)row.FindControl("uxUserNameLabelDisplayer");

            GridViewRow user = (GridViewRow)myUserName.NamingContainer;
            MembershipUser myUser = (MembershipUser)user.DataItem;


            if (activeCheckBox.Checked == true)
            {
                uxMessageDisplayer.Text = "T - Aproved User";
                myUser.IsApproved = true;
                Membership.UpdateUser(myUser);
            }
            else
            {
                uxMessageDisplayer.Text = "F - NOT Aproved User";
                myUser.IsApproved = false;
                Membership.UpdateUser(myUser);
            }
        }



这是格式,有关更多信息,请访问 http://stackoverflow.com/questions/3939942 /asp-net-membershipuser-retrive-data-from-gridview [ ^ ]



this is the format more information visit http://stackoverflow.com/questions/3939942/asp-net-membershipuser-retrive-data-from-gridview[^]


 SqlConnection cn = new SqlConnection("Your ConnectionsString here");
SqlCommand cmd = new SqlCommand("Query to Retrieve data from                database",cn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "Data");

gridview.DataSource = ds.Tables[0];
gridview.DataBind();


这篇关于如何在网格视图中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 01:27