N
Nathan Baulch
I am trying to build a WebCustomControl that I can use in multiple web
applications.
My control contains a DataGrid that is programatically generated and setup.
I want the DataGrid to be sortable.
AllowSort = true and SortExpression is set for all columns.
However the resulting grid does not have hyper link column headers.
On closer inspection, the header labels are wraped in <a> tags, but there is
no href attribute.
If I programmatically setup a DataGrid in the Page_Load of a page, it works
fine.
Here is the code from the Render override of my control:
DataGrid grid = new DataGrid();
grid.AllowSorting = true;
grid.AutoGenerateColumns = false;
BoundColumn col = new BoundColumn();
col.DataField = "ONE";
col.HeaderText = "ONE";
col.SortExpression = "ONE";
grid.Columns.Add(col);
col = new BoundColumn();
col.DataField = "TWO";
col.HeaderText = "TWO";
col.SortExpression = "TWO";
grid.Columns.Add(col);
col = new BoundColumn();
col.DataField = "THREE";
col.HeaderText = "THREE";
col.SortExpression = "THREE";
grid.Columns.Add(col);
DataTable t = new DataTable();
t.Columns.Add("ONE");
t.Columns.Add("TWO");
t.Columns.Add("THREE");
t.Rows.Add(new string[] {"1","2","3"});
t.Rows.Add(new string[] {"4","5","6"});
t.Rows.Add(new string[] {"7","8","9"});
grid.DataSource = t;
grid.DataBind();
grid.RenderControl(output);
Why isn't my grid filling the href attributes of the header titles?
Nathan
applications.
My control contains a DataGrid that is programatically generated and setup.
I want the DataGrid to be sortable.
AllowSort = true and SortExpression is set for all columns.
However the resulting grid does not have hyper link column headers.
On closer inspection, the header labels are wraped in <a> tags, but there is
no href attribute.
If I programmatically setup a DataGrid in the Page_Load of a page, it works
fine.
Here is the code from the Render override of my control:
DataGrid grid = new DataGrid();
grid.AllowSorting = true;
grid.AutoGenerateColumns = false;
BoundColumn col = new BoundColumn();
col.DataField = "ONE";
col.HeaderText = "ONE";
col.SortExpression = "ONE";
grid.Columns.Add(col);
col = new BoundColumn();
col.DataField = "TWO";
col.HeaderText = "TWO";
col.SortExpression = "TWO";
grid.Columns.Add(col);
col = new BoundColumn();
col.DataField = "THREE";
col.HeaderText = "THREE";
col.SortExpression = "THREE";
grid.Columns.Add(col);
DataTable t = new DataTable();
t.Columns.Add("ONE");
t.Columns.Add("TWO");
t.Columns.Add("THREE");
t.Rows.Add(new string[] {"1","2","3"});
t.Rows.Add(new string[] {"4","5","6"});
t.Rows.Add(new string[] {"7","8","9"});
grid.DataSource = t;
grid.DataBind();
grid.RenderControl(output);
Why isn't my grid filling the href attributes of the header titles?
Nathan