CheckBoxList
<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>
In CodeBehind ,
To Insert
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();
}
}
}
To Update in GridView
string[] qual = Edu.Split(' ');
for (int i = 0; i < qual.Length; i++)
{
for (int j = 0; j < Edu_ChkBxLst. Items.Count; j++)
{
if (qual[i].Contains(Edu_ChkBxLst.Items[j].Text.Trim()))
{
Edu_ChkBxLst.Items[j].Selected = true;
}
}
}
ListBox
<asp:ListBox ID="LB_Tech_Knowledge" runat="server" TabIndex="7"
SelectionMode="Multiple">
<asp:ListItem Value="0">Dot Net</asp:ListItem>
<asp:ListItem Value="1">SQL Server</asp:ListItem>
<asp:ListItem Value="2">AJAX</asp:ListItem>
<asp:ListItem Value="3">WebService</asp:ListItem>
<asp:ListItem Value="4">JSON</asp:ListItem>
<asp:ListItem Value="5">LINQ</asp:ListItem>
<asp:ListItem Value="6">JQuery</asp:ListItem>
<asp:ListItem Value="7">MVC</asp:ListItem>
</asp:ListBox>
In CodeBehind ,
To Insert
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();
}
}
}
To Update in GridView
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
int index = Convert.ToInt32(e.CommandArgument);
RadioButtonList
<asp:RadioButtonList ID="RBList_Color" runat="server" RepeatColumns="2"
RepeatDirection="Horizontal" TabIndex="9">
<asp:ListItem Value="0" Text="Green"></asp:ListItem>
<asp:ListItem Value="1" Text="Yellow"></asp:ListItem>
<asp:ListItem Value="2" Text="Orange"></asp:ListItem>
<asp:ListItem Value="3" Text="Blue"></asp:ListItem>
</asp:RadioButtonList>
In CodeBehind ,
To Insert
_pro_Reg.FavColor = RBList_Color.SelectedItem.Text.ToString();
To Update in GridView
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
int index = Convert.ToInt32(e.CommandArgument);
string fav = GridView1.Rows[index].Cells[9].Text.Trim();
for (int j = 0; j < RBList_Color.Items.Count; j++)
{
if (fav.Contains(RBList_Color.Items[j].Text.Trim()))
{
RBList_Color.Items[j].Selected = true;
}
}
RadioButton
<asp:RadioButton ID="RBtn_Male" GroupName="Gender" Text="Male" TabIndex="5" runat="server" />
<asp:RadioButton ID="RBtn_Female" GroupName="Gender" Text="Female" runat="server" />
In CodeBehind ,
To Insert
if (RBtn_Female.Checked)
{
_pro_Reg.Gender = RBtn_Female.Text;
}
else
{
_pro_Reg.Gender = RBtn_Male.Text;
}
To Update in GridView
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
int index = Convert.ToInt32(e.CommandArgument);
string gender = GridView1.Rows[index].Cells[5].Text.Trim();
if (gender == "Male")
{
RBtn_Male.Checked = true;
}
if (gender == "Female")
{
RBtn_Female.Checked = true;
}
<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>
In CodeBehind ,
To Insert
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();
}
}
}
To Update in GridView
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
int index = Convert.ToInt32(e.CommandArgument);
string Edu = GridView1.Rows[index].Cells[6].Text.Trim();{
if (e.CommandName == "Edit")
{
int index = Convert.ToInt32(e.CommandArgument);
string[] qual = Edu.Split(' ');
for (int i = 0; i < qual.Length; i++)
{
for (int j = 0; j < Edu_ChkBxLst. Items.Count; j++)
{
if (qual[i].Contains(Edu_ChkBxLst.Items[j].Text.Trim()))
{
Edu_ChkBxLst.Items[j].Selected = true;
}
}
}
ListBox
<asp:ListBox ID="LB_Tech_Knowledge" runat="server" TabIndex="7"
SelectionMode="Multiple">
<asp:ListItem Value="0">Dot Net</asp:ListItem>
<asp:ListItem Value="1">SQL Server</asp:ListItem>
<asp:ListItem Value="2">AJAX</asp:ListItem>
<asp:ListItem Value="3">WebService</asp:ListItem>
<asp:ListItem Value="4">JSON</asp:ListItem>
<asp:ListItem Value="5">LINQ</asp:ListItem>
<asp:ListItem Value="6">JQuery</asp:ListItem>
<asp:ListItem Value="7">MVC</asp:ListItem>
</asp:ListBox>
In CodeBehind ,
To Insert
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();
}
}
}
To Update in GridView
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
int index = Convert.ToInt32(e.CommandArgument);
string LB_Tech = GridView1.Rows[index].Cells[7].Text.Trim();
string[] tec = LB_Tech.Split(',');
for (int i = 0; i < tec.Length; i++)
{
for (int j = 0; j < LB_Tech_Knowledge.Items.Count;j++)
{
if (tec[i].Contains(LB_Tech_Knowledge.Items[j].Text.Trim()))
{
LB_Tech_Knowledge.Items[j].Selected = true;
}
}
}
RadioButtonList
<asp:RadioButtonList ID="RBList_Color" runat="server" RepeatColumns="2"
RepeatDirection="Horizontal" TabIndex="9">
<asp:ListItem Value="0" Text="Green"></asp:ListItem>
<asp:ListItem Value="1" Text="Yellow"></asp:ListItem>
<asp:ListItem Value="2" Text="Orange"></asp:ListItem>
<asp:ListItem Value="3" Text="Blue"></asp:ListItem>
</asp:RadioButtonList>
In CodeBehind ,
To Insert
_pro_Reg.FavColor = RBList_Color.SelectedItem.Text.ToString();
To Update in GridView
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
int index = Convert.ToInt32(e.CommandArgument);
string fav = GridView1.Rows[index].Cells[9].Text.Trim();
for (int j = 0; j < RBList_Color.Items.Count; j++)
{
if (fav.Contains(RBList_Color.Items[j].Text.Trim()))
{
RBList_Color.Items[j].Selected = true;
}
}
RadioButton
<asp:RadioButton ID="RBtn_Male" GroupName="Gender" Text="Male" TabIndex="5" runat="server" />
<asp:RadioButton ID="RBtn_Female" GroupName="Gender" Text="Female" runat="server" />
In CodeBehind ,
To Insert
if (RBtn_Female.Checked)
{
_pro_Reg.Gender = RBtn_Female.Text;
}
else
{
_pro_Reg.Gender = RBtn_Male.Text;
}
To Update in GridView
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
int index = Convert.ToInt32(e.CommandArgument);
string gender = GridView1.Rows[index].Cells[5].Text.Trim();
if (gender == "Male")
{
RBtn_Male.Checked = true;
}
if (gender == "Female")
{
RBtn_Female.Checked = true;
}