Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom Header in GridView
    text
    copied!<p>I've already got my custom header drawing in my GridView using SetRenderMethodDelegate on the header row within the OnRowCreated method. I'm having problems trying to add LinkButtons to the new header row though.</p> <p>This is what the RenderMethod looks like:</p> <pre><code>private void RenderSelectionMode(HtmlTextWriter output, Control container) { TableHeaderCell cell = new TableHeaderCell(); cell.Attributes["colspan"] = container.Controls.Count.ToString(); AddSelectionModeContents(cell); cell.RenderControl(output); output.WriteEndTag("tr"); HeaderStyle.AddAttributesToRender(output); output.WriteBeginTag("tr"); for(int i = 0; i &lt; container.Controls.Count; i++) { DataControlFieldHeaderCell cell = (DataControlFieldHeaderCell)container.Controls[i]; cell.RenderControl(output); } } private void AddSelectionModeContents(Control parent) { // TODO: should add css classes HtmlGenericControl label = new HtmlGenericControl("label"); label.InnerText = "Select:"; selectNoneLK = new LinkButton(); selectNoneLK.ID = "SelectNoneLK"; selectNoneLK.Text = "None"; //selectNoneLK.Attributes["href"] = Page.ClientScript.GetPostBackClientHyperlink(selectNoneLK, ""); //selectNoneLK.Click += SelectNoneLK_Click; selectNoneLK.Command += SelectNoneLK_Click; selectAllLK = new LinkButton(); selectAllLK.ID = "SelectAllLK"; selectAllLK.Text = "All"; //selectAllLK.Attributes["href"] = Page.ClientScript.GetPostBackClientHyperlink(selectAllLK, ""); //selectAllLK.Click += SelectAllLK_Click; selectAllLK.Command += SelectAllLK_Click; parent.Controls.Add(label); parent.Controls.Add(selectNoneLK); parent.Controls.Add(selectAllLK); } </code></pre> <p>As you can see, I have tried different ways to get my LinkButtons working (none have worked though). The LinkButtons are rendered as plain anchor tags, like this: &lt;a id="SelectNoneLK"&gt;None&lt;/a&gt;</p> <p>I know there is something wrong with the fact that the ID looks like that, since I am using a Master page for this and the ID should be something much longer.</p> <p>Any help would be appreciated!</p> <p>Nick</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload