Problem In datagrid/dataview

Discussion in 'General Computer Support' started by webaccess, Jan 7, 2008.

  1. webaccess

    webaccess

    Joined:
    Jan 7, 2008
    Messages:
    2
    Location:
    india
    Hi Friends ..!!

    I want to use datagrid/dataview control to data in tablular format,also I want to add paging and format the data of table column.

    Problem is data is coming from API Dom in as XML source. Now to display data i hv use dataset to fetch data.so i m displaying data in datagrid/dataview.

    Now here comes a problem:

    Using Datagrid :

    Paging event is not fired.only the page refreshes and paging is not happening.

    Code:

    <script runat="server">

    Dim objData as New data.DataSet

    Protected Sub gridViewPublishers_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)
    gridViewPublishers.PageIndex = e.NewPageIndex
    'gridViewPublishers.Columns(2).ToString().Format("dd/MMM/yyyy",)
    gridViewPublishers.DataBind()
    End Sub
    </script>

    Dim s As String
    Dim i As Integer

    Dim str As String
    Dim storeXml as string
    Dim objAPI As New CAPI
    Dim lXMLDepartureDOM As New MSXML2.DOMDocument
    Dim lXMLDeptNodeList As MSXML2.IXMLDOMNodeList
    Dim lXMLDeptNode As MSXML2.IXMLDOMNode
    Dim lXMLTourMedia As MSXML2.IXMLDOMNode

    str = "<brand>Cosmos</brand><tourCode>" & Request.QueryString("tourcode") & "</tourCode><pricingModel>USA</pricingModel>"
    lXMLDepartureDOM = objAPI.CallAPI("GetDeparturesXML", str)
    If (Request.QueryString("tourcode").EndsWith(1)) Then
    lXMLDepartureDOM = objAPI.CallAPI("GetGSADeparturesXML", str)
    Else
    lXMLDepartureDOM = objAPI.CallAPI("GetDeparturesXML", str)
    End If
    lXMLDeptNodeList = lXMLDepartureDOM.selectNodes("//Departure")
    Dim storeCount as integer = lXMLDeptNodeList.length
    Dim countMod as integer = lXMLDeptNodeList.length
    storeCount = (storeCount/11)
    'storeXml= lXMLDepartureDOM
    'Dim sDate As DateTime
    i = 0

    storeXml = lXMLDepartureDOM.xml
    'Dim objData as New data.DataSet
    Dim xmlData As String = lXMLDepartureDOM.xml

    Dim xmlSR As System.IO.StringReader = New System.IO.StringReader(xmlData)

    objData.ReadXml(xmlSR, Data.XmlReadMode.Auto).ToString()

    DataGrid2.Datasource = objData.Tables(6)
    DataGrid2.Databind()

    %>

    <asp:DataGrid id="DataGrid2" AllowPaging="true" AllowCustomPaging="false" AlternatingItemStyle-BackColor="white" OnPageIndexChanged="DataGrid2_PageIndexChanged" PageSize=10 PagerStyle-Mode="NumericPages" runat="server" AutoGenerateColumns="False" GridLines="Vertical" width="100%" class="PriceBox" cellspacing="0" border="0"
    BorderStyle="None" BackColor="White" AllowSorting="true">
    <ItemStyle ForeColor="Black" BackColor="#F0EDED"></ItemStyle>
    <HeaderStyle Font-Bold="True" Font-Names="Verdana" Font-Size="8px" Height="25px" ForeColor="White" BackColor="Black" ></HeaderStyle>
    <FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle>
    <Columns>
    <asp:BoundColumn HeaderStyle-CssClass="trPriceBoxHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" DataFormatString="{0:d}" HeaderText="Tour Start Date" DataField="LandStartDate"></asp:BoundColumn>
    <asp:BoundColumn HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderText="Return Date" DataFormatString="{0:dd-MMM-yyyy}" DataField="LandEndDate"></asp:BoundColumn>
    <asp:BoundColumn HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderText="Land/Cruise Price" DataFormatString="{0:C3}" DataField="LandOnlyPrice"></asp:BoundColumn>
    <asp:BoundColumn HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderText="Status" DataField="Status"></asp:BoundColumn>
    <asp:HyperLinkColumn HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderText="Status" NavigateUrl="" ></asp:HyperLinkColumn>
    </Columns>
    <PagerStyle Position="Bottom" HorizontalAlign="Left" ForeColor="" BackColor="" ></PagerStyle>
    </asp:DataGrid>

    Now Using dataview

    Paging is done but only once and to do paging again i hv to start MS developer.
    also to format string ,i made HTMLEncode = false

    Code :

    <script runat="server">

    Dim objData as New data.DataSet

    Protected Sub CustomersGridView_PageIndexChanged(ByVal sender As Object, ByVal e As EventArgs)

    ' Call a helper method to display the current page number
    ' when the user navigates to a different page.
    'DisplayCurrentPage()
    gridViewPublishers.PageIndex = e.NewPageIndex
    'gridViewPublishers.Columns(2).ToString().Format("dd/MMM/yyyy",)
    gridViewPublishers.DataBind()

    End Sub
    </script>

    <%
    Dim s As String
    Dim i As Integer

    Dim str As String
    Dim storeXml as string
    Dim objAPI As New CAPI
    Dim lXMLDepartureDOM As New MSXML2.DOMDocument
    Dim lXMLDeptNodeList As MSXML2.IXMLDOMNodeList
    Dim lXMLDeptNode As MSXML2.IXMLDOMNode
    Dim lXMLTourMedia As MSXML2.IXMLDOMNode

    str = "<brand>Cosmos</brand><tourCode>" & Request.QueryString("tourcode") & "</tourCode><pricingModel>USA</pricingModel>"
    lXMLDepartureDOM = objAPI.CallAPI("GetDeparturesXML", str)
    If (Request.QueryString("tourcode").EndsWith(1)) Then
    lXMLDepartureDOM = objAPI.CallAPI("GetGSADeparturesXML", str)
    Else
    lXMLDepartureDOM = objAPI.CallAPI("GetDeparturesXML", str)
    End If
    lXMLDeptNodeList = lXMLDepartureDOM.selectNodes("//Departure")
    Dim storeCount as integer = lXMLDeptNodeList.length
    Dim countMod as integer = lXMLDeptNodeList.length
    storeCount = (storeCount/11)
    'storeXml= lXMLDepartureDOM
    'Dim sDate As DateTime
    i = 0

    storeXml = lXMLDepartureDOM.xml
    'Dim objData as New data.DataSet
    Dim xmlData As String = lXMLDepartureDOM.xml

    Dim xmlSR As System.IO.StringReader = New System.IO.StringReader(xmlData)

    objData.ReadXml(xmlSR, Data.XmlReadMode.Auto).ToString()

    gridViewPublishers.Datasource = objData.Tables(6)
    gridViewPublishers.Databind()
    %>

    <asp:GridView ID="gridViewPublishers" runat="server" AllowPaging="true" AutoGenerateColumns="false" OnPageIndexChanged="CustomersGridView_PageIndexChanged" PagerSettings-Mode="Numeric" PagerSettings-Position="Bottom" PageSize="10" width="100%">
    <HeaderStyle Font-Bold="True" Font-Names="Verdana" Font-Size="11px" Height="25px" ForeColor="White" BackColor="Black" ></HeaderStyle>
    <Columns>
    <asp:BoundField DataField="LandStartDate" HtmlEncode="false" DataFormatString="{0:$#,##0.00;($#,##0.00);0}" ItemStyle-HorizontalAlign="Center" HeaderText="Tour Start Date" />
    <asp:BoundField DataField="LandEndDate" HtmlEncode="false" ItemStyle-HorizontalAlign="Center" HeaderText="Return Date" />
    <asp:BoundField DataField="LandOnlyPrice" HtmlEncode="false" DataFormatString="{0:c}" ItemStyle-HorizontalAlign="Center" HeaderText="Land/Cruise Price" SortExpression="Fax" />
    <asp:BoundField ApplyFormatInEditMode="true" DataField="Status" HtmlEncode="false" ItemStyle-HorizontalAlign="Center" HeaderText="Status"/>

    </Columns>
    </asp:GridView>

    Please Help me regarding above problem..

    Thanks
    Parijaat Shah
    (Software Developer- Webaccess India Pvt Ltd)
    webaccess, Jan 7, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kawabzi

    About Datagrid Columns

    Kawabzi, Sep 22, 2003, in forum: MCSD
    Replies:
    2
    Views:
    433
  2. jacksu
    Replies:
    5
    Views:
    24,002
    Rugen
    Apr 20, 2007
  3. Daniel Joskovski

    Re: Problems facing in datagrid pagecount

    Daniel Joskovski, Apr 7, 2004, in forum: MCSD
    Replies:
    0
    Views:
    451
    Daniel Joskovski
    Apr 7, 2004
  4. Daniel Joskovski

    Re: Problems facing in datagrid pagecount

    Daniel Joskovski, Apr 8, 2004, in forum: MCSD
    Replies:
    0
    Views:
    494
    Daniel Joskovski
    Apr 8, 2004
  5. adolf
    Replies:
    4
    Views:
    478
    The Poster Formerly Known as Kline Sphere
    Jun 7, 2004
Loading...

Share This Page