Here is my aspx designing code for checkboxlist
<tr>
<td class="style3">
<asp:Label ID="Label7" runat="server" Text="Education" CssClass="style2"></asp:Label>
</td>
<td>
<asp:CheckBoxList ID="Edu_ChkBxLst" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="0" Text="Diploma"></asp:ListItem>
<asp:ListItem Value="1" Text="UG" > </asp:ListItem>
<asp:ListItem Value="2" Text="PG"></asp:ListItem>
<asp:ListItem Value="3" Text="MPhil/PhD"></asp:ListItem>
</asp:CheckBoxList>
</td>
<td>
</td>
</tr>
The following coding is used for save/insert
protected void Btn_Save_Click(object sender, EventArgs e)
{
_pro_Reg.FName = txt_FName.Text;
_pro_Reg.LName = txt_LName.Text;
_pro_Reg.UName = txt_UName.Text;
_pro_Reg.Pwd = txt_Pwd.Text;
if (RBtn_Female.Checked)
{
_pro_Reg.Gender = RBtn_Female.Text;
}
else
{
_pro_Reg.Gender = RBtn_Female.Text;
}
foreach (ListItem li in Edu_ChkBxLst.Items)
{
if (li.Selected)
{
if (_pro_Reg.Education == null)
{
_pro_Reg.Education = li.Text.ToString();
}
else
{
_pro_Reg.Education = _pro_Reg.Education + "," + li.Text.ToString();
}
}
}
foreach (ListItem li in LB_Tech_Knowledge.Items)
{
if (li.Selected)
{
if (_pro_Reg.Tech == null)
{
_pro_Reg.Tech = li.Text.ToString();
}
else
{
_pro_Reg.Tech = _pro_Reg.Tech + "," + li.Text.ToString();
}
}
}
foreach (ListItem li in ChkBoxList_Relocation.Items)
{
if (li.Selected)
{
if (_pro_Reg.Reloc == null)
{
_pro_Reg.Reloc = li.Text.ToString();
}
else
{
_pro_Reg.Reloc = _pro_Reg.Reloc + "," + li.Text.ToString();
}
}
}
_pro_Reg.FavColor = RBList_Color.SelectedItem.Text.ToString();
_pro_Reg.Continent = DDL_Continent.SelectedItem.Text.ToString();
_pro_Reg.Country = DDL_Country.SelectedItem.Text.ToString();
_pro_Reg.City = DDL_City.SelectedItem.Text.ToString();
_pro_Reg.MailID = txt_MailID.Text;
_pro_Reg.Mobno = txt_Mobno.Text;
if (Btn_Save.Text == "Save")
{
b.insert(_pro_Reg);
Response.Write("The Value has been Added successfully");
}
My problem is that,
i am unknown to update in Gridview those who selected value from Checkboxlist...
my intention is that i have to save more than one item from checkboxlist and update them in GridView....
i have done for Radiobutton...
I have attached my GridView coding below...
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
int index = Convert.ToInt32(e.CommandArgument);
Session["UserID"] = GridView1.DataKeys[index].Value.ToString();
txt_FName.Text = GridView1.Rows[index].Cells[1].Text.Trim();
txt_LName.Text = GridView1.Rows[index].Cells[2].Text.Trim();
txt_UName.Text = GridView1.Rows[index].Cells[3].Text.Trim();
txt_Pwd.Text = GridView1.Rows[index].Cells[4].Text.Trim();
string gender = GridView1.Rows[index].Cells[5].Text.Trim();
if (gender == "Male")
{
RBtn_Male.Checked = true;
}
if (gender == "Female")
{
RBtn_Female.Checked = true;
}
string Edu = GridView1.Rows[index].Cells[6].Text.Trim();
}