Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can any one help me to run out of problem.

am using checkboslist control in which after checking the check boxes am saving in DB like (checkboxvalue,checkboxvalue.........)
ex:(1,2,3,)

when am trying to retrive from dataBase
am seperating from ',' and moving round in for loop

Ex
for (int i = 0; i < GroupCodes.Length; i++)
{
if (GroupCodes.Substring(i,1) != ",")
{
GroupTypeChkBxLst.SelectedValue = GroupCodes.Substring(i, 1);

}
}

by using this last value is getting selected, all other previous values get unchecking
Posted

1 solution

Well, you need to change your code and use:
Checkboxlist.Items property[^]

In your for loop, if you find a particular checkboxlistitem saved as selected then do something like: checkboxlist1.Items[i].Selected
 
Share this answer
 
Comments
karthikkushala 7-Dec-10 5:35am    
protected void loanProductsGv_SelectedIndexChanged(object sender, EventArgs e)
{
SaveImgBtn.Visible = false;
UpdateeImgBtn.Visible = true;
GridViewRow row = (GridViewRow)loanProductsGv.SelectedRow;
try
{
ProductIDLbl.Text = Server.HtmlDecode(row.Cells[0].Text);
LoanTypeDdl.SelectedValue = Server.HtmlDecode(row.Cells[9].Text);
LoanProductNameTxt.Text = Server.HtmlDecode(row.Cells[2].Text);
CreationDateTxt.Text=Server.HtmlDecode(row.Cells[3].Text);
LoanCategoryTxt.Text = Server.HtmlDecode(row.Cells[4].Text);
LoanLedgerCodeCmBox.SelectedItem.Text = Server.HtmlDecode(row.Cells[11].Text);
LoanLedgerNameCmBox.SelectedValue = Server.HtmlDecode(row.Cells[11].Text);
InsertLedgerNameCmBox.SelectedValue = Server.HtmlDecode(row.Cells[12].Text);
InterestLedgerCodeCmBox.SelectedItem.Text = Server.HtmlDecode(row.Cells[12].Text);
string GroupCodes = Server.HtmlDecode(row.Cells[10].Text);

for (int i = 0; i < GroupCodes.Length; i++)
{

if (GroupCodes.Substring(i,1) != ",")
{
GroupTypeChkBxLst.SelectedValue = GroupCodes.Substring(i, 1);
}
}


}
catch (Exception ex)
{
log.Error(ex.Message, ex);
}

}
problem is not while insertion when getting from DB
am storing in DB (1,2,4,5,)

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