Created
August 28, 2013 04:48
-
-
Save monyskynet/6362236 to your computer and use it in GitHub Desktop.
Create custome datetemplate in gridview
From http://www.devexpress.com/Support/Center/Question/Details/Q101226
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[C#]Open in popup windowpublic class MyTemplate : ITemplate | |
{ | |
public void InstantiateIn(Control container) | |
{ | |
HtmlAnchor control = new HtmlAnchor(); | |
control.Name = "Hyper1"; | |
control.Attributes.Add("onclick", "alert('dd')"); | |
container.controls.Add(control); | |
} | |
} | |
protected void Page_Load(object sender, EventArgs e) | |
{ | |
GridViewDataHyperLinkColumn column = null; | |
if (ASPxGridView1.Columns["New"] == null) | |
{ | |
column = new GridViewDataHyperLinkColumn(); | |
ASPxGridView1.Columns.Add(column); | |
column.FieldName = "New"; | |
} | |
else | |
column = ASPxGridView1.Columns["New"] as GridViewDataHyperLinkColumn; | |
column.DataItemTemplate = new MyTemplate(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment