hi,
In my below code while i am executing i am getting below exception please suggest where i need to update.
- void CmbHospitalsSelectedIndexChanged(object sender, EventArgs e)
- {
- try
- {
- WebClient wc = new WebClient();
- wc.Headers["Content-type"] = "application/x-www-form-urlencoded";
- NameValueCollection collection = new NameValueCollection();
- collection.Add("hid","0");
- collection.Add("sno", "2");
- byte[] bret = wc.UploadValues(URLAuth, collection);
- string sret = "";
- sret = System.Text.Encoding.ASCII.GetString(bret);
- int count=0;
- string[,] husers ;
-
- if (sret != "")
- {
- XmlDocument readDoc = new XmlDocument();
- readDoc.LoadXml(sret);
- count = readDoc.SelectNodes("hospitalusers/huids").Count;
- husers = new string[count, 4];
-
- XmlNodeList xhuid = readDoc.GetElementsByTagName("huid");
- XmlNodeList xuser_name = readDoc.GetElementsByTagName("user_name");
- for (int i= 0; i < count; i++)
- {
- husers[i,0] = xhuid[i].InnerText;
- husers[i, 4] = xuser_name[i].InnerText;
- }
-
- cmbhusers.DisplayMember="text";
- cmbhusers.ValueMember="key";
-
- for (int i = 0; i < husers.GetLength(0); i++)
- {
- cmbhusers.Items.Add(new { Text = husers[i, 4], Key=Convert.ToInt16(husers[i,0])});
- }
- }
- }
- catch (NullReferenceException e1)
- {
- MessageBox.Show(e1.Message);
- }