Hello,
I have a GridView that I put inside an update panel.
I have a control that attaches to the datasource of the gridview that filters the data, databinds the gridview and then updates the update panel that the gridview is in.
In my page render I put this so I could select a row by just clicking it.
The row select works great on the first render of the page. However when I filter my gridview or just update the update panel my onclick attribute is not rendered in the ajax postback.
First hit of page
Capture of http ajax post using fiddler
Haaaalp! I'm not sure what is happening. The style attributes I put on in my rowdatabound event. The filter control I'm using does not seem to be the culprit because it is only touching my object datasource. So it must be something going on due my grid being in an update panel. Is there something about Update Panels that remove onclick or prevent the rendering in an ajax postback? I've stepped through and the attribute seems to be added in the Render... I'm at a complete loss. Any ideas???
I have a GridView that I put inside an update panel.
I have a control that attaches to the datasource of the gridview that filters the data, databinds the gridview and then updates the update panel that the gridview is in.
In my page render I put this so I could select a row by just clicking it.
Code:
protected override void Render(HtmlTextWriter writer) { foreach (GridViewRow row in GridView1.Rows) { if (row.RowType == DataControlRowType.DataRow) { row.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(GridView1, "Select$" + row.RowIndex.ToString(), true)); } } Page.ClientScript.RegisterForEventValidation(GridView1.UniqueID); base.Render(writer); }
First hit of page
Code:
<tr onMouseOver="this.style.cursor='hand'; this.style.background='yellow';" onMouseOut="this.style.background='#FFFFFF';" onclick="__doPostBack('ctl00$ContentPlaceHolder1$CustomControl1$GridView1','Select$0')" style="color:#333333;background-color:White;"><td>mydata</td></tr>
Code:
<tr onMouseOver="this.style.cursor='hand'; this.style.background='yellow';" onMouseOut="this.style.background='#FFFFFF';" style="color:#333333;background-color:White;"><td>mydata</td></tr>
Comment