GridView, DataKeyNames

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

Hey there,

I have a GridView on an ASP.NET / VB page and currently it has an attribute
called DataKeyNames which has a reference to an XML attribute name, for
example.

<asp:GridView CssClass="gridview" ID="mygridview" runat="server"
AllowSorting="True" Width="100%"
AutoGenerateColumns="False"
AllowPaging="True"
GridLines="None"
DataKeyNames="id"

....

xml snipette of row data

<xmlnode id="0" param1="" param2="" />



This works fine, but I am trying to change it to XML Elements rather than
attributes, i.e.

<xmlnode>
<id>0</id>
<param1></param1>
<param2></param2>
</xmlnode>

Unfortunately I'm not quite sure what to enter into DataKeyNames to allow
the section via Element, any ideas how I do this? At current when I try to
bind the data I just get told that id can't be found.

Many thanks in advance for your help!

Nick.
 
Hi there,

Not to worry now, I have managed to resolve this issue by keeping the id
as an attribute but changing all the other params to elements. The DataItem
has to be typecast to an IXPathNavigable object during population of the
grid and CreateNavigator is called and used in order to obtain the element
values.

Nick.
 
Back
Top