I have a grid. First the grid row is filled with row id (ie.”tr” id) but when a button clicked (.Net Ajax) page gets refreshed. Then grid row id will disappear. How can this issue be resolved. I mean i need to retain row id when grid gets refreshed through Ajax call.
More clarity with call of ajax, grid row is losing the id. I need to retain that value. Is any method for that? Please help me.
protected void grd_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", "javascript:ChangeRowColor(" + e.Row.ClientID + ")");
}
}
Above is the code, after refreshing with ajax method, its row id gets null. So, at runtime i’m getting js error like id is not defined.
Are you saying that
e.Row.ClientIDis null or empty after the postback? Instead of passing the ID of the row, just pass the row itself usingthis:By doing this, you no longer have to use
document.getElementByIdeither, since the element will be passed in as an argument:EDIT: This is a quick & dirty solution, but you can use a global variable to keep track of the previously selected row.