Dynamic TemplateField in GridView
xcgeek | Posted 8:43am 22. August 2005 Server Time |
I am working on a gridview page with an Update All type solution as detailed here: http://fredrik.nsquared2.com/viewpost.aspx?PostID=202
I also want to dynamically add columns which I have gotten a start on with the following code:
Dim TmpFld as new TemplateField
TmpFld.HeaderText = "J"
TmpFld.SortExpression = "J"
But I still have to figure out the databinding, and implementing the itemtemplate as a checkbox. I have found good explaination about this with the DataGrid (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchcreatingwebservercontroltemplatesprogrammatically.asp)
but I can't help but think these methods are now outdated with the GridView in 2.0
Does anyone have any experience with this. Thanks
This post have been closed for new replies
Informant | Posted 9:51am 22. August 2005 Server Time ||
everything that you are talking about you can do via the designer and configuration properties in visual studio 2005 then instead of setting a datasource and databinding you just set a datasourceid and everything happens implicitly.
xcgeek | Posted 11:21am 22. August 2005 Server Time |
I don't see how you can do this with the designer and configuration properties as each gridview column looks something like this in order to get the Update All effect:
<asp:TemplateField HeaderText="Release" SortExpression="ReleasePermission">
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Permission") %>' />
I have the gridview databound to a declarative SQLDataSource , But I can't set AutoGenerateColumns to true if I'm delaring each ItemTemplate like this. The reason I want to add columns dynamically is due to the fact I don't know at design time what columns will be returned from the query.
Any solution to this conundrum
xcgeek | Posted 11:06am 27. August 2005 Server Time |
I've found a few bugs with the GridView control when it comes to adding dynamic columns. How do I go about reporting these bugs to MS.
R Casquete | Posted 8:34am 15. June 2007 Server Time |
this Control has many bugs!!!!!
I have found a weird BUG:
when creating the Template columns at runtime; If I asign anything to the HeaderText or to the SortExpression, then the Template is not added, and when the process is inside the RowDataBound Method, no controls has been added to the cells.
Show all replies to 'Dynamic TemplateField in GridView'