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());
}
}


Amit GuptaRank #190 · 12.8K reputationPosted Aug 30, 2017, 10:02 AM EDT
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 !
Amit GuptaRank #190 · 12.8K reputationPosted Aug 30, 2017, 1:01 AM EDT
Zakir AhamedRank #1,545 · 1K reputationPosted Aug 30, 2017, 2:38 AM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Aug 30, 2017, 3:39 AM EDT
Zakir AhamedRank #1,545 · 1K reputationPosted Aug 30, 2017, 4:02 AM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Aug 30, 2017, 4:17 AM EDT
Zakir AhamedRank #1,545 · 1K reputationPosted Aug 30, 2017, 4:40 AM EDT
James AxsomRank #4,887 · 320 reputationPosted Jun 20, 2018, 12:15 PM EDT