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
rosemary
NA
57
20.8k
Error : Index was outside the bounds of the array
May 29 2018 4:34 AM
There is a problem in my code and i am not aware how to resolve this .
My Error is
Index was outside the bounds of the array
. when i am passing 1 or 2 value through query string it gives error. please help me and resolve my problem if anybody can.
Thnkx in adv.
GridViewRow gr = (GridViewRow)((Button)sender).NamingContainer;
string
userid = gdvdetails.DataKeys[gr.RowIndex].Values[0].ToString();
string
jobid = gdvdetails.DataKeys[gr.RowIndex].Values[1].ToString();
Response.Redirect(
"view_userprofile.aspx?cid="
+ userid +
"gid="
+ jobid);
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
try
{
if
(Request.QueryString[
"cid"
].ToString() !=
""
)
{
//string id = Request.QueryString["cid"].ToString();
var q1 = (Request.QueryString.ToString());
var qs = q1.Split(
'&'
);
var qs1 = (qs[0].Split(
'='
));
hdfuserid.Value = qs1[1];
var qs2 = qs[1].Split(
'='
);
hdfjobid.Value = qs2[1];
Session[
"vid"
] = hdfjobid.Value.ToString();
SqlCommand cmd =
new
SqlCommand(
"select * from user_profile where uid='"
+ hdfuserid.Value +
"'and jid='"
+ hdfjobid +
"'"
, Con);
SqlDataAdapter da =
new
SqlDataAdapter(cmd);
DataTable dt =
new
DataTable();
da.Fill(dt);
if
(dt.Rows.Count > 0)
{
lblfname.Text = dt.Rows[0][
"fname"
].ToString();
lbllname.Text = dt.Rows[0][
"lname"
].ToString();
lbladdress.Text = dt.Rows[0][
"address"
].ToString();
lblfathername.Text = dt.Rows[0][
"fathername"
].ToString();
lblmothername.Text = dt.Rows[0][
"mothername"
].ToString();
lblfoccu.Text = dt.Rows[0][
"foccu"
].ToString();
lblmoccu.Text = dt.Rows[0][
"moccu"
].ToString();
lblmob.Text = dt.Rows[0][
"mob"
].ToString();
lblplace.Text = dt.Rows[0][
"place"
].ToString();
lbl10percen.Text = dt.Rows[0][
"tenth"
].ToString();
lblplustwo.Text = dt.Rows[0][
"plustwo"
].ToString();
lbldegree.Text = dt.Rows[0][
"degree"
].ToString();
lblkeyskill.Text = dt.Rows[0][
"keyskills"
].ToString();
lblexp.Text = dt.Rows[0][
"exp"
].ToString();
}
}
}
catch
(Exception ex)
{
Response.Write(
"Error"
);
}
}
}
Reply
Answers (
2
)
Facebook streaming
DataTables warning: table id=dataTable - Invalid JSON respon