|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
excel datasource and gridview sortingI am somewhat befuddled. I have a gridview that I have filled using oledb datareader with data from an excel sheet.(code at bottom) My problem is that it does not sort and I can't figure out why. If I import to access and create a datasource using the table in access I imported from all is well. But when I fill it with the reader sorting has no effect. the code below works for gridview1 which uses a access datasource but the first one is uneffected. I have set allowsorting = true on both. But only the second one is sorting both by the button and by clicking on the hyperlink in the header. Can anyone tell me what I need to get the excel to sort? Thanks for your interest! Len Protected Sub btnSort_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSort.Click Dim direction As SortDirection direction = SortDirection.Ascending ExcelOut.Sort("Attending", direction) AccessGridView1.Sort("Attending", direction) ========PageLoad===================================================== Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then Dim DBConnection = New OleDbConnection( _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & Me.MapPath("Upload/DailyInfo.xls") & ";" & _ "Extended Properties=""Excel 8.0;HDR=Yes""") DBConnection.Open() Dim strConnString As String = Me.MapPath("Upload/DailyInfo.xls") Dim SQLString As String = "SELECT Hospital,[Room],[Patient Name],DOB,Symptom,Notes,Attending,Consulting ,[Initial Date Seen],FU FROM [INPATIENT PATIENT SVCS$]" Dim DBCommand = New OleDbCommand(SQLString, DBConnection) Dim DBReader As OleDbDataReader = DBCommand.ExecuteReader() ExcelOut.DataSource = DBReader ExcelOut.DataBind() DBReader.Close() DBConnection.Close() End If End Sub Html:================================ <asp:GridView ID="ExcelOut" runat="server" Width="800px" CellPadding="4" ForeColor="#333333" GridLines="None" AllowSorting="True" AutoGenerateColumns="False"> <Columns> <asp:BoundField DataField="HOSPITAL" HeaderText="HOSPITAL" SortExpression="HOSPITAL" /> <asp:BoundField DataField="Room" HeaderText="Room" SortExpression="Room" /> <asp:BoundField DataField="Patient Name" HeaderText="Patient Name" SortExpression="Patient Name" /> <asp:BoundField DataField="DOB" HeaderText="DOB" SortExpression="DOB" /> <asp:BoundField DataField="Symptom" HeaderText="Symptom" SortExpression="Symptom" /> <asp:BoundField DataField="Notes" HeaderText="Notes" SortExpression="Notes" /> <asp:BoundField DataField="Attending" HeaderText="Attending" SortExpression="Attending" /> <asp:BoundField DataField="Consulting" HeaderText="Consulting" SortExpression="Consulting" /> <asp:BoundField DataField="Initial Date Seen" HeaderText="Initial Date Seen" SortExpression="Initial Date Seen" /> <asp:BoundField DataField="FU" HeaderText="FU" SortExpression="FU" /> </Columns> <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#FFFBD6" ForeColor="#333333" /> <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" /> <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" /> <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="White" /> </asp:GridView> a.. b.. c.. Report abuse -------------------------------------------------------------------------------- |
|||||||||||||||||||||||