Click here to Skip to main content
15,894,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a User privilege form,where i load grid from Administrator table,further i insert data from Grid view with a check box property in a new User table in database, it works perfectly. But in next condition I want to load grid from both of two tables, first User Table where the data is shown with check box checked true property, and the second Administrator table, where data is shown with check box checked false property.if u understand my question, so please help me.My Code is:

C#
protected void CmdUserRights_Click(object sender, ImageClickEventArgs e) 
{
StrSql = "Select Name from Sys.tables";
        StrSql = StrSql + " Where Name='" + "User_" + CboUserId.Text + "'"; 
        DataSet rs = (DataSet)MethodClass.ConnectionToQuery(StrSql);

        if (rs.Tables[0].Rows.Count <= 0)
           {
            StrSql = "Select * from User_Administrator";
            StrSql = StrSql + " Order by serial_no asc";
            DataSet rs2 = (DataSet)MethodClass.ConnectionToQuery(StrSql);
            GvUserPrivilege.DataSource = rs2.Tables[0];
            GvUserPrivilege.DataBind();
            }
        else
        {
            StrSql = "Select * from " + "[User_" + CboUserId.Text + "]";
            StrSql = StrSql + " Order By serial_no asc ";
            DataSet rs4 = (DataSet)MethodClass.ConnectionToQuery(StrSql);
            if (rs4.Tables[0].Rows.Count > 0)
               {
                GvUserPrivilege.DataSource = rs4.Tables[0];
                GvUserPrivilege.DataBind();
                foreach (GridViewRow rows in GvUserPrivilege.Rows)
                  {
                   CheckBox ChkBoxRows = (CheckBox)rows.FindControl("chk");
                   ChkBoxRows.Checked = true;
                  }
               }
            else
               {
               }
            }
}
Posted
Updated 19-Dec-14 20:09pm
v2

1 solution

Merge two dataset in a single dataset by creating a database and using .Merge function for dataset table and the using distinct feature of it
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900