i have 3 tables one is Tbl_Project(projectcode PK ,projectname,remarks) ; Tbl_users(usercode PK,username); Tbl_Clientprojects(projectcode FK,usercode FK) and have one web form in which i have dropdownlist (in which projectname from Tbl_project arethere); i have gridview1 (in which all username with their respective code are there and with one more column checkbox to select to which users to make select respective project which will be selected from dropdownlist) and one <b>OK </b>button(whose work is to insert the project code to respective usercode (which is checked in checkbox)) and respective user when they login respective account should get only their information about the project assigned to them ) i have achieved all this but problem arised when one user get multiple projects.it is showing only one project.following code:
foreach (GridViewRow r in GridView1.Rows)
{
ch = (CheckBox)(r.FindControl("checkSelect"));
if (ch.Checked)
{
userCode = r.Cells[1].Text;
objquery.assign_pro(projectCode, userCode, userType, status,s,s1,s,s1);
}
}
public void assign_pro(string projectCode, string userCode, string userType, string status, string CreatedBy, string created_date, string ModifiedBy, string modified_date)
{
objdl.DMLQuery("insert into Tbl_ClientProject values('" + projectCode + "','" + userCode + "','" + userType + "','" + status + "','" + CreatedBy + "','" + created_date + "','" + ModifiedBy + "','" + modified_date + "' )");
}
public void DMLQuery(string commText)
{
comm = new SqlCommand(commText, conn);
comm.Transaction = trans;
comm.ExecuteNonQuery();
}
til here it is working correct i.e one user is assigned with multiple projects
now when user open its project after login as user to whom only its project should be shown
protected void Page_Load(object sender, EventArgs e)
{
lblWelcome.Text = "Welcome " + Session["UserId"];
string s=Session["UserId"].ToString();
dt= objquery.get_clientprojectcode(s);
string s1 = dt.Rows[0]["ProjectCode"].ToString();
dt = objquery.get_clientprojects(s1);
foreach (DataRow dr in dt.Rows)
{
string s1 = dr["ProjectCode"].ToString();
dt1 = objquery.get_clientprojects(s1);
}
GridViewuser.DataSource = dt1;
GridViewuser.DataBind(); }
public DataTable get_clientprojects(string pid)
{
return (objdl.getData("select ProjectName,Remarks from Tbl_Project where ProjectCode='" + pid + "'"));
}
public DataTable getData(string commText)
{
adapt = new SqlDataAdapter(commText, conn);
dt = new DataTable();
adapt.Fill(dt);
return dt;
}
in
dt it is showing only one record assigned to it but in table there are two records
here i have assigned 2 projects to this user ...this user only getting one project shown in grid not 2
pls tell how can i achieve
regards