TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
abburi chowdary
NA
60
15k
Index was outside the bounds of the array C#
Apr 26 2018 12:37 AM
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];
// alternately, _doc.Load( _strFilename); to read from a file.
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);
}
Reply
Answers (
2
)
WPF app for pattern generated by intersecting circles
How can we clear data in combobx2 on selecting next item in