Last post Feb 11, 2008 09:09 PM by hyperbolix
Feb 08, 2008 04:02 PM|hyperbolix|LINK
Focused on very exciting Dynamic Data thare are already pretty stable with latest mid december CTP, I detected one behaviour that could be a bug.
<asp:LinqDataSource ID="ds1" runat="server" ContextTypeName="Northwind.NorthwindDataContext" TableName="Products"/>
<asp:DynamicGridView runat="server" ID="dgv" DataKeyNames="ProductID,CategoryID,SupplierID" DataSourceID="ds1" />
DataKeyNames property of DynamicGridView has a length of: <%= dgv.DataKeyNames.Length %>
Displays 1 as a result, when same code using a classic
GridView perfectly behaves and returns an expected 3.
Can anybody confirm this same bug appears outside of me ?
Has anybody any idea to fix it myself by derivating my own DynamicGridView while waiting the next ASP.NET 3.6 release.
Thanks to Microsoft team for such breakthrough in data web application agility.
ASP.NET 3.5 Extensions
Feb 11, 2008 09:09 PM|hyperbolix|LINK
I finally find an acceptable work around myself and propose to share it here.
I discover that the DynamicGridView DataKeyNames property is forced during the OnInit event to contain the list of primary keys of the table associated with the LinqDataSource.
So by derivating DynamicGridView and providing an overriden event for the OnInit, this solves my issue:
protected override void OnInit(EventArgs e)
string oldDataKeyNames = this.DataKeyNames; // Save DataKeyNames as declared
if (oldDataKeyNames.Length > 0)
this.DataKeyNames = oldDataKeyNames; // Restore original declaration