abburi chowdary

abburi chowdary

  • NA
  • 60
  • 14.9k

How can we get the exact datain combobox2 on selecting comb1

Apr 30 2018 12:58 AM
hi,
 
I have two comboboxes were in combobo1 i have data of hospitals and linked hospital users to combobox but while i running the outpit i amnot getting exact list of users who all under certain hopspital, how can we get the same
  1. void CmbHospitalsSelectedIndexChanged(object sender, EventArgs e)  
  2. {  
  3. try  
  4. {  
  5. dynamic refobj = cmbHospitals.SelectedItem;  
  6. MessageBox.Show(refobj.Key);  
  7. cmbhusers.SelectedIndex = -1;  
  8. cmbhusers.Items.Clear();  
  9. if(true)  
  10. {  
  11. WebClient wc = new WebClient();  
  12. wc.Headers["Content-type"] = "application/x-www-form-urlencoded";  
  13. NameValueCollection collection = new NameValueCollection();  
  14. collection.Add("hid",cmbHospitals.SelectedIndex.ToString());  
  15. collection.Add("sno""4");  
  16. byte[] bret = wc.UploadValues(URLAuth, collection);  
  17. string sret = "";  
  18. sret = System.Text.Encoding.ASCII.GetString(bret);  
  19. int count=0;  
  20. string[,] husers ;  
  21. if (sret != "")  
  22. {  
  23. XmlDocument readDoc = new XmlDocument();  
  24. readDoc.LoadXml(sret);  
  25. count = readDoc.SelectNodes("hospitalusers/huids").Count;  
  26. husers = new string[count, 2];  
  27. XmlNodeList xhuid = readDoc.GetElementsByTagName("huid");  
  28. XmlNodeList xuser_name = readDoc.GetElementsByTagName("user_name");  
  29. for (int i= 0; i < count; i++)  
  30. {  
  31. husers[i,0] = xhuid[i].InnerText;  
  32. husers[i, 1] = xuser_name[i].InnerText;  
  33. }  
  34. cmbhusers.DisplayMember="text";  
  35. cmbhusers.ValueMember="key";  
  36. for (int i = 0; i < husers.GetLength(0); i++)  
  37. {  
  38. cmbhusers.Items.Add(new { text = husers[i, 1], key=Convert.ToInt16(husers[i,0])});  
  39. }  
  40. }  
  41. }  
  42. }  
  43. catch (NullReferenceException e1)  
  44. {  
  45. MessageBox.Show(e1.Message);  
  46. }  
  47. }