Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #11 (permalink)  
Old September 5th, 2006, 06:48 AM
Friend of Wrox
 
Join Date: Oct 2005
Location: , , United Kingdom.
Posts: 173
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Would you know if there is a way of sharing my initial DataSet of data (that I used to fill the Gridview in the first place) between classes as I would like to set up sorting as a separate class but can't see how unless I go through using the DataAdapter.fill again.

Tell me if I am making this harder than it should be.. I am sort of going with instinct here.

Many thanks

Rit
Reply With Quote
  #12 (permalink)  
Old September 5th, 2006, 06:56 AM
Authorized User
 
Join Date: Sep 2006
Location: , , India.
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
  Write a simple class with a method which returns dataset.U can fill dataset here and return that dataset.
   Now U can use(Share) this dataset by calling this method whnever u want the dataset

class simpleclass{

public static System.Data.Dataset GetProducts()
{
--do data access ,fill the dataset---
return ds;

}
}

Another class{

Dataset MyDataset = simpleclass.GetProducts();
}

Think u must got the point.

Reply With Quote
  #13 (permalink)  
Old September 6th, 2006, 06:50 AM
Friend of Wrox
 
Join Date: Oct 2005
Location: , , United Kingdom.
Posts: 173
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks SriRamaKrishna and all,

I know I am really close to having this sorted!.. I have re-used my class which produces the initial dataset (called dbconnection for this example) within my Sorting class as described in your kind response. But this produces the following error:

ExecuteReader: CommandText property has not been initialized

This error refers to the following line within my code within the class dbconnection:

myDataAdapter.Fill(MyDataSet, "reporttbl")

I can't seem to get my head around how to resolve this. Would you have any ideas?

Thank you for your help!

Rit
Reply With Quote
  #14 (permalink)  
Old September 6th, 2006, 10:17 AM
Friend of Wrox
 
Join Date: Oct 2005
Location: , , United Kingdom.
Posts: 173
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Ignore my last post. It was me getting my code in a twist.

My final question if I may... The sorting seems to order my Gridview columns within ASC order. Is there a way to also order them in DESC order?

Many thanks

Rit
Reply With Quote
  #15 (permalink)  
Old September 9th, 2006, 10:26 PM
Authorized User
 
Join Date: Sep 2006
Location: , , India.
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi ,
 Yes ,While assigning sort expression in Dataview.Sort Property.
eg.
 Dataview.Sort= "Column name DESC"

Better Luck

Reply With Quote
  #16 (permalink)  
Old March 22nd, 2007, 03:34 AM
Registered User
 
Join Date: Mar 2007
Location: PUNE, MAHARASHTRA, India.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

HIIII....IM HAVING PROBLEM IN SORTING GRIDVIEW THE ERROR MESSAGE IS LIKE...
the gridview 'GRIDVIEW1' fired event sorting which wasn't handled

I TRIED TO BIND GRID IN GRIDVIEW_SORTING EVENT...
BUT STILL IT NOT WORKS...MY CODE LIKE

Imports System.Data.OleDb
Imports System.IO
Imports System.Web.UI.Design
Imports System.Data
Imports PublicFunctions
Imports Microsoft.VisualBasic.Interaction
Imports Microsoft.VisualBasic.MsgBoxStyle
Public Class empsearch
    Inherits System.Web.UI.Page
    Dim conn As New OleDbConnection
    Dim da As New OleDbDataAdapter
    Dim cmd As New OleDbCommand
    Dim reader As OleDbDataReader
    Dim ds As New DataSet
    Dim constr As String
    Dim dbpath As String
    Dim p As PublicFunctions = New PublicFunctions
    Dim str As String
    Dim loginname As String
    Public Shared fields4(11) As String

    Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging
        GridView1.PageIndex = e.NewPageIndex
        formfill()
    End Sub

    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
        Dim Code As String = GridView1.SelectedRow.Cells(1).Text
        If (Request.QueryString("name") = "edit") Then
            Response.Redirect("~/empedit.aspx?Code=" & Code & "&LoginId=" & loginname)
        ElseIf (Request.QueryString("name") = "delete") Then
            Response.Redirect("~/empdelete.aspx?Code=" & Code & "&LoginId=" & loginname)
        ElseIf (Request.QueryString("name") = "view") Then
            Response.Redirect("~/empview.aspx?Code=" & Code & "&LoginId=" & loginname)
        Else
        End If

    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'If (Request.QueryString("name") = "view") Then
        ' GridView1.AutoGenerateSelectButton = False
        'Else
        ' GridView1.AutoGenerateSelectButton = True
        'End If
        loginname = Request.QueryString("LoginId")
        If (Not IsPostBack) Then

            conn = p.GetAccessConn(Me)
            Dim Table As String = Request.QueryString("master")
            cmd.CommandText = "Select * from " & Table & " "
            cmd.Connection = conn
            reader = cmd.ExecuteReader
            Dim i As Integer

            For i = 0 To 10
                fields4(i) = ""
            Next
            For i = 0 To reader.FieldCount - 1
                dropfield.Items.Add(reader.GetName(i).ToString)
                fields4(i) = (reader.GetName(i).ToString)
                If (i = 5) Then
                    Exit For
                End If

            Next
            lblmsg.Text = " Select " & Table & " record to " & Request.QueryString("name")
            reader.Close()
            conn.Close()
        End If

    End Sub

    Protected Sub btnsearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsearch.Click
        formfill()
    End Sub
    Sub formfill()
        If (Page.IsPostBack = True) Then
            lblmsg.Text = ""
            p.search("Employee", fields4, "Code", txtsearch.Text)
        End If
        Dim i As Integer
        Dim qry As String
        conn = p.GetAccessConn(Me)
        Dim Table As String = Request.QueryString("master")
        qry = p.search(Table, fields4, dropfield.SelectedValue.ToString, txtsearch.Text)
        GridView1.DataSource = p.myoledataset(Me, qry, "employee")
        GridView1.DataBind()
        For i = 3 To GridView1.Columns.Count - 1
            GridView1.Columns(i).Visible = False
        Next
        conn.Close()
    End Sub

    Protected Sub GridView1_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles GridView1.Sorting
        formfill()
    End Sub
End Class



Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting GridView with a Collection as DataSource+ danielpilon C# 7 June 10th, 2008 04:20 PM
Disp Footer even no record in GridView Datasource mallikalapati ASP.NET 2.0 Professional 1 March 19th, 2008 02:23 AM
chapter about object datasource and gridview? asptwodev BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 November 2nd, 2007 12:53 PM
Gridview for inser,update without using datasource karthikeyan_pa ASP.NET 2.0 Professional 0 September 4th, 2007 07:58 AM
GridView DataSource Abbas C# 2005 0 November 28th, 2006 01:54 PM



All times are GMT -4. The time now is 09:32 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.