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
Himanshu Tyagi
NA
119
15.8k
How to find id using hiddenfield in gridview on button click
Feb 2 2018 3:35 AM
My update button is outside gridview
I am trying but its showing error "Object reference not set to an instance of an object." on "string strhfId = (gvRow.FindControl("hfId") as HiddenField).Value;"
I have tried different too
HiddenField hfId = (HiddenField)gridData.SelectedRow.Cells[0].FindControl("hfId");
but error is same
protected void lnkUpdate_Click(object sender, EventArgs e)
{
//HiddenField hfId = (HiddenField)gridData.SelectedRow.Cells[0].FindControl("hfId"); // Error is here
//HiddenField strId = ((HiddenField)gridData.Rows[0].FindControl("hfIdValue"));
//String value = strId.Value;
LinkButton btn = sender as LinkButton;
GridViewRow gvRow = btn.NamingContainer as GridViewRow;
string strhfId = (gvRow.FindControl("hfId") as HiddenField).Value; // Error is here
try
{
//HiddenField hfIdc = (HiddenField)gridData.SelectedRow.Cells[0].FindControl("hfIdValue");
List
parameters = new List
{
};
parameters.Add(new SqlParameter("@P_APPLICATION_ID", strhfId));
parameters.Add(new SqlParameter("@P_APPLICATION_NAME", txtApplicationName.Text));
parameters.Add(new SqlParameter("@P_MODE", "E"));
string strResponse = objAppFunctionModule.ExecuteNonQueryMethod(strUSP_APPLICATION_MST, parameters);
PopulateGrid();
}
catch (Exception ex)
{
lblResponse.Text = ex.Message;
}
}
Reply
Answers (
7
)
Selactable Image.
How to avoid to not add new row in DB , When i Edit User's