473,405 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Problem In Datagrid/DataView

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_PageIndexCha nged" 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)
Jan 7 '08 #1
0 1639

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Billy Jacobs | last post by:
I have created a DataGridColumnDatePicker Component so that I can put a datetimepicker control in my datagrid. It almost works. When I put my mouse in the cell it changes to a datetimepicker...
8
by: Rodusa | last post by:
I am getting an error on line 133. I am trying to update a datarow using the find method, but it keeps throwing the error below: int ItemKey = dv.Find(Item.inv_mast_uid); DataRow dr; if...
3
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
8
by: Inigo Jimenez | last post by:
I have an ASP .net web application installed in a Windows 2003 server. This web application has a webform that has a Datagrid. This Datagrid is filled with the data of a SQL table. I have a...
2
by: ddaniel | last post by:
I have read many posts and seen many papers on the different techniques for sort and filtering datagrids. Many do re-queries against the dB ala Fritz Onion. I am trying to leverage the Dataview....
6
by: Ron L | last post by:
I have a dataset whose source is a SQL 2k stored procedure that I am trying to display in a datagrid. This datasource has 4 columns that I am interested in here, a text column and 3 value columns...
0
by: Bob Davies | last post by:
Hi I have a webservice that retrieves data from a database, this is then returned to the calling client application built in windows forms within a dataset, however upon attempting to create...
3
by: astro | last post by:
I have a datagrid that is two levels down from the dataview (i.e. grandchild). I have spent 3 hours trying to get the syntax of determining it's real datasource (i.e. not it's source based on it's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.