Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
DataBind() problem.Gives "NO Data to Display", though Datasource is filled with Data.
posted

Hi

I am very new to Infragistics controls.I am using XmlNodeList as my Datasource for UltraWebGrid . Though I can see my entire Data in the Datasource List (during debug) , am not able to bind the data to my grid. Can somebody pls help me. Its urgent .... Thanks in advance. Part of the code is as below .....

XmlDataDocument xmlout;

XmlNodeList nodes = null;

protected void UltraWebGrid1_InitializeDataSource(object sender, UltraGridEventArgs e)

{

this.UltraWebGrid1.DataSource = makeData(uSession,"");

this.UltraWebGrid1.DataBind();

}

protected XmlNodeList makeData(UniSession uSession, string condition)

{

try

{

if (uSession != null)

{

xmlout = pg.GridContent(uSession, "");              // where pg is my webservice returning XmlDataDocument .....

if (xmlout != null)

{

nodes = xmlout.SelectNodes("ROOT/STOCK");

return nodes;

}

else

return nodes;

}

else

return nodes;

}

finally

{

if (uSession != null || uSession.IsActive)

uSession.Dispose();

uSession = null;

}

}

The part of XML generated is as below ...

 <ROOT>
<STOCK>
  <_ID>6651134</_ID>
  <CSCI/>
  <STCPIDATE>01/01/1968</STCPIDATE>
  <STEXCSEC/>
  <STAMNDDATE/>
</STOCK>
<STOCK>
  <_ID>0056489</_ID>
  <CSCI>RES</CSCI>
  <STCPIDATE/>
  <STEXCSEC>021</STEXCSEC>
  <STAMNDDATE>04/04/2008</STAMNDDATE>
</STOCK>
<STOCK>

 

The UltraWebGrid Columns are as below :

<igtbl:TemplatedColumn BaseColumnName="CSCI" HeaderClickAction="SortSingle" IsBound="True"

Key="CSCI" NullText="AB">

<CellTemplate>

<asp:Label ID="Label1" runat="server" Text='<%# ((System.Xml.XmlNode)(Container.DataItem))["CSCI"].InnerText %>'></asp:Label>

</CellTemplate>

<Header Caption="CSCI" ClickAction="SortSingle">

</Header>

<ValueList DataMember="CSCI" DisplayStyle="DataValue" Key="CSCI">

</ValueList>

</igtbl:TemplatedColumn>

<igtbl:TemplatedColumn BaseColumnName="STCPIDATE" IsBound="True" Key="STCPIDATE"

NullText="AB">

<CellTemplate>

<asp:Label ID="Label2" runat="server" Text='<%# ((System.Xml.XmlNode)(Container.DataItem))["STCPIDATE"].InnerText %>'></asp:Label>

</CellTemplate>

<Header Caption="STCPIDATE">

<RowLayoutColumnInfo OriginX="1" />

</Header>

<Footer>

<RowLayoutColumnInfo OriginX="1" />

</Footer>

<ValueList DataMember="STCPIDATE" DisplayStyle="DataValue" Key="STCPIDATE">

</ValueList>

</igtbl:TemplatedColumn>

<igtbl:TemplatedColumn BaseColumnName="STEXCSEC" DataType="System.Int32" IsBound="True"

Key="STEXCSEC" NullText="12">

<CellTemplate>

<asp:Label ID="Label3" runat="server" Text='<%# ((System.Xml.XmlNode)(Container.DataItem))["STEXCSEC"].InnerText %>'></asp:Label>

</CellTemplate>

<Header Caption="STEXCSEC">

<RowLayoutColumnInfo OriginX="2" />

</Header>

<Footer>

<RowLayoutColumnInfo OriginX="2" />

</Footer>

<ValueList DataMember="STEXCSEC" DisplayStyle="DataValue" Key="STEXCSEC">

</ValueList>

</igtbl:TemplatedColumn>

<igtbl:TemplatedColumn BaseColumnName="STAMNDDATE" IsBound="True" Key="STAMNDDATE"

NullText="AB">

<CellTemplate>

<asp:Label ID="Label4" runat="server" Text='<%# ((System.Xml.XmlNode)(Container.DataItem))["STAMNDDATE"].InnerText %>'></asp:Label>

</CellTemplate>

<Header Caption="STAMNDDATE">

<RowLayoutColumnInfo OriginX="3" />

</Header>

<Footer>

<RowLayoutColumnInfo OriginX="3" />

</Footer>

<ValueList DataMember="STAMNDDATE" DisplayStyle="DataValue" Key="STAMNDDATE">

</ValueList>

</igtbl:TemplatedColumn>

</Columns>

 

Parents
  • 28464
    posted

    Hello,

    Thanks for writing and for your interest in our products. I believe the easiest way to bind XML to the UltraWebGrid is to read the XML into DataSet, and then bind it to grid. It is just a couple of line of code - here is a sample approach

     string xmlString = @" <ROOT>
                                    <STOCK>
                                      <_ID>6651134</_ID>
                                      <CSCI/>
                                      <STCPIDATE>01/01/1968</STCPIDATE>
                                      <STEXCSEC/>
                                      <STAMNDDATE/>
                                    </STOCK>
                                    <STOCK>
                                      <_ID>0056489</_ID>
                                      <CSCI>RES</CSCI>
                                      <STCPIDATE/>
                                      <STEXCSEC>021</STEXCSEC>
                                      <STAMNDDATE>04/04/2008</STAMNDDATE>
                                    </STOCK>
                                    </ROOT>";

            DataSet ds = new DataSet();
            StringReader sr = new StringReader(xmlString);
            ds.ReadXml(sr);
          

            UltraWebGrid1.DataSource = ds;
            UltraWebGrid1.DataBind();

     Hope this helps.

     

Reply Children