Hi Everyone...
In my web application.. i Have a database table with following values
---------------------------------------
Menu . . . . . . . . . Add Update level
----------------------------------------
ctl00_PartyPro....... 1 . . . 0 . . . 1
ctl00_EmpPro......... 1 . . . 0 . . . 1
ctl00_TransPro....... 0 . . . 1 . . . 1
ctl00_LoadMas........ 0 . . . 1 . . . 1
ctl00_UomMas........ 1 . . . 1 . . . 1
ctl00_ItemMas....... 1 . . . 1 . . . 1
ctl00_Invoice......... 0 . . . 1 . . . 1
ctl00_RptPrint........ 1 . . . 0 . . . 1
ctl00_ChkPwd........ 1 . . . 1 . . . 1
-----------------------------------
i need to retrieve this value to gridview,,
in that gridview i have 4 columns ,that columns like
Label1,Checkbox1,Checkbok2,Label2...
In this, that add and update column values if 1 means that check box should be checked, else it shouldnot be check...
i wrote cs code like below but it showing error..
protected void Button3_Click(object sender, EventArgs e)
{
con.Open();
string RR = "select Master,Canadd,CanUpdate,UserLevel FROM Tbl_Com_UserRights WHERE Userlevel='" + DDUserLvl.Text + "'";
cmd = new SqlCommand(RR,con);
dr = cmd.ExecuteReader();
I1 = 0;
while(dr.Read())
{
((Label)(GridView1.Rows[I1].Cells[0].FindControl("Label1"))).Text = dr.GetString(0);
ra = Convert.ToInt32(dr.GetValue(1));
rb = Convert.ToInt32(dr.GetValue(2));
if (ra == 1)
{
((CheckBox)(GridView1.Rows[I1].Cells[1].FindControl("CheckBox1"))).Checked = true;
}
else
{
((CheckBox)(GridView1.Rows[I1].Cells[1].FindControl("CheckBox1"))).Checked = false;
}
if (rb == 1)
{
((CheckBox)(GridView1.Rows[I1].Cells[2].FindControl("CheckBox2"))).Checked = true;
}
else
{
((CheckBox)(GridView1.Rows[I1].Cells[2].FindControl("CheckBox2"))).Checked = false;
}
((Label)(GridView1.Rows[I1].Cells[0].FindControl("Label2"))).Text = dr.GetString(3);
I1 = I1 + 1;
}
dr.Close();
}
Am Getting the Following Error...
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
is it possible to get solution.. plz help me....