mahmoud mousaa
New member
- Joined
- Aug 28, 2020
- Messages
- 1
- Programming Experience
- 5-10
I use these code to retrieve data from checkedlistbox selected and show data in datagrideview
problem query retrieve data one checkedlistbox selected not multi checkedlistbox selected I want to retrieve data in datagrideview with multi checkedlistbox selected
Mod Edit, please don't bold your text, it's an eyesore.
problem query retrieve data one checkedlistbox selected not multi checkedlistbox selected I want to retrieve data in datagrideview with multi checkedlistbox selected
C#:
string s = "";
int x;
for (x = 0; x <= checkedListBox1.CheckedItems.Count - 1; x++)
{
s = "'" + checkedListBox1.CheckedItems[x].ToString() + "',";
}
s = s.Substring(0, s.Length - 1);
con = new SqlConnection(cs.DBConn);
con.Open();
cmd = new SqlCommand("select id,'',raqam,name_sender,country1,country2,tel1,tel2,title,detalis,n_number,price,ship,total,name from pos where country2 IN("+s+") order by id asc ", con);
rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
bunifuCustomDataGrid1.Rows.Clear();
while (rdr.Read() == true)
{
bunifuCustomDataGrid1.Rows.Add(rdr[0], rdr[1], rdr[2], rdr[3], rdr[4], rdr[5], rdr[6], rdr[7], rdr[8], rdr[9], rdr[10], rdr[11], rdr[12], rdr[13], rdr[14]);
bunifuCustomDataGrid1.Rows.OfType<DataGridViewRow>().Last().Selected = true;
bunifuCustomDataGrid1.CurrentCell = bunifuCustomDataGrid1.Rows[bunifuCustomDataGrid1.Rows.Count - 1].Cells[1];
}
con.Close();
Mod Edit, please don't bold your text, it's an eyesore.
Last edited by a moderator: