hi this is my code i have selected values prblem:
else if (btncategory.Text == "Update")
{
string ChkSelectedValue = string.Empty;
//object chBoxListTables = null;
for (int i = 0; i < clbbrand.Items.Count; i++)
{
if (clbbrand.Items[i].Selected) -->> prblm Selected**
{
ChkSelectedValue = clbbrand.Items[i].Value + ','; -->> Value** Passing Prblm
}
}
//int Items = 0;
//for (int i = 0; i < clbbrand.Items.Count; i++)
//{
// if (clbbrand.Items[i].Selected)
// //if(clbbrand.SelectedIndex > 0)
// {
// ChkSelectedValue = chBoxListTables.Items[i].Value+ ',';
// }
//}
Hashtable hstbl = new Hashtable();
DataGridViewRow row = GvCategory.Rows[indexRow];
hstbl.Add("@status", "update");
hstbl.Add("@CategoryId", Convert.ToInt32(row.Cells[0].Value));
hstbl.Add("@updatedby", Global.UserID);
hstbl.Add("@BrandId",ChkSelectedValue);
Int64 dt = DataAccessLayer.ExecuteCommand_RowsAffected("Category_Mst_sp", hstbl);
if (dt >= 0)
{
MessageBox.Show("Category Details Updated Sucessfully", "Category Alert");
txtcategory.Text = string.Empty;
LoadCategory();
btncategory.Text = "SAVE";
}
else
{
MessageBox.Show("Already Entered the Category");
}
}
}
else
{
string title = "Category";
MessageBox.Show("Please Enter the Category", title);
}
}
catch (Exception exceptionObj)
{
MessageBox.Show(exceptionObj.Message.ToString());
}
}
8 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

James AxsomPosted Jun 20, 2018, 4:15 PM
Amit GuptaPosted Aug 30, 2017, 2:02 PM
Why you are using
if (clbbrand.GetItemChecked(i))
Please understand the code, what is it doing and for what purpose it was being implemented, as we are looping through CheckedIndices, it will only loop through the checked items.
Moreover, your question was quite confusing and not clear to understand the requirement, please be specific to the question you are asking for. Your question is changing on every post.
Be straight forward to your question like
1. What should be the output
2. What should be the input.
3. What should ve the best possible way to resolve the issue.
Consider the above points before asking any question, so that one can understand what is the issue because its only you who know the requirement.
Hope you understood !
Zakir AhamedPosted Aug 30, 2017, 8:40 AM
Amit GuptaPosted Aug 30, 2017, 8:17 AM
Zakir AhamedPosted Aug 30, 2017, 8:02 AM
Amit GuptaPosted Aug 30, 2017, 7:39 AM
Zakir AhamedPosted Aug 30, 2017, 6:38 AM
Amit GuptaPosted Aug 30, 2017, 5:01 AM