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
Harshal Kulkarni
NA
26
9.5k
how to assign linkbutton name in gridview
Jan 24 2017 5:23 AM
I'm getting object reference error..
my code is :
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
foreach (GridViewRow r in GridView1.Rows)
{
LinkButton lbl = (LinkButton)r.Cells[1].FindControl("LinkButton1");
//LinkButton lbl = (LinkButton)e.Row.FindControl("LinkButton1") as LinkButton;
string str = r.Cells[0].Text;
string str1 = str.Substring(0, str.IndexOf("(")).Trim();
if (str1 == "Abnormal")
{
con.Open();
cmd = new OracleCommand("", con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
lbl.Text = dr[0].ToString();
//r.Cells[1].Text = dr[0].ToString();
}
con.Close();
}
else if (str1 == "Sub-Normal")
{
con.Open();
cmd = new OracleCommand(" ", con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
lbl.Text = dr[0].ToString();
//r.Cells[1].Text = dr[0].ToString();
}
con.Close();
}
else if (str1 == "Normal")
{
con.Open();
cmd = new OracleCommand("", con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
lbl.Text = dr[0].ToString();
//r.Cells[1].Text = dr[0].ToString();
}
con.Close();
}
else if (str1 == "Critical")
{
con.Open();
cmd = new OracleCommand("", con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
lbl.Text = dr[0].ToString();
//r.Cells[1].Text = dr[0].ToString();
}
con.Close();
}
else if (str1 == "Super Critical")
{
con.Open();
cmd = new OracleCommand("", con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
lbl.Text = dr[0].ToString();
//r.Cells[1].Text = dr[0].ToString();
}
con.Close();
}
}
}
}
Thanks in advanced.
Reply
Answers (
3
)
How can pass more than one file type in view to controller ?
how to send all mail using c#