Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 22nd, 2007, 03:52 AM
Registered User
 
Join Date: Mar 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default SORTING IN GRIDVIEW

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



Plzzzz solve my probbbb...

thanksss






Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView Sorting Aker C# 7 May 29th, 2008 07:50 AM
Sorting and Paging of gridview lily611 C# 2005 0 April 24th, 2008 03:09 AM
GridView sorting error snufse ASP.NET 2.0 Basics 0 February 12th, 2008 06:00 PM
Sorting GridView DARSIN ASP.NET 2.0 Basics 0 December 14th, 2004 09:36 AM
Re:Sorting gridview m_rajib .NET Framework 2.0 2 December 14th, 2004 08:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.