Click here to Skip to main content
15,900,108 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionCreating a HTML page from ASP.NET Pin
whozurmommy20-Aug-06 21:54
whozurmommy20-Aug-06 21:54 
AnswerRe: Creating a HTML page from ASP.NET Pin
ChinmayV21-Aug-06 1:42
ChinmayV21-Aug-06 1:42 
QuestionDown load video file from data base & play it in own browser Pin
kushak_manoj20-Aug-06 21:32
kushak_manoj20-Aug-06 21:32 
QuestionSorting in Grid View using AJAX Pin
Kartik Rathi20-Aug-06 21:17
Kartik Rathi20-Aug-06 21:17 
AnswerRe: Sorting in Grid View using AJAX Pin
vik2021-Aug-06 3:34
vik2021-Aug-06 3:34 
GeneralRe: Sorting in Grid View using AJAX Pin
Kartik Rathi22-Aug-06 1:03
Kartik Rathi22-Aug-06 1:03 
GeneralRe: Sorting in Grid View using AJAX Pin
vik2022-Aug-06 1:19
vik2022-Aug-06 1:19 
QuestionSorting in Grid View Pin
Kartik Rathi20-Aug-06 21:13
Kartik Rathi20-Aug-06 21:13 
I want to do sorting in Grid View with help of coding.This is my code
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
getdata()
End Sub

Public Function getdata() As DataSet
Dim adp As New SqlDataAdapter("select CategoryID,CategoryName,Description from categories order by CategoryName ASC", ConfigurationManager.ConnectionStrings("cn").ConnectionString)
Dim dt As New DataTable("categories")
adp.Fill(dt)
Dim dtrowcount As Integer = dt.Rows.Count
If dtrowcount > 0 Then
GridView1.DataSource = dt
GridView1.DataBind()
End If

End Function


Private Property GridViewSortDirection() As String
Get
Return IIf(ViewState("SortDirection") = Nothing, "DESC", ViewState("SortDirection"))
End Get
Set(ByVal value As String)
ViewState("SortDirection") = value
End Set
End Property

Private Property GridViewSortExpression() As String
Get
Return IIf(ViewState("SortExpression") = Nothing, String.Empty, ViewState("SortExpression"))
End Get
Set(ByVal value As String)
ViewState("SortExpression") = value
End Set
End Property

Private Function GetSortDirection() As String
Select Case GridViewSortDirection
Case "ASC"
GridViewSortDirection = "DESC"

Case "DESC"
GridViewSortDirection = "ASC"
End Select
Return GridViewSortDirection
End Function

Protected Function SortDataTable(ByVal datatable As DataTable, ByVal isPageIndexChanging As Boolean) As DataView
If Not datatable Is Nothing Then
Dim dataView As New DataView(datatable)
If GridViewSortExpression <> String.Empty Then
If isPageIndexChanging Then
dataView.Sort = String.Format("{0} {1}", GridViewSortExpression, GridViewSortDirection)
Else
dataView.Sort = String.Format("{0} {1}", GridViewSortExpression, GetSortDirection())
End If
End If
Return dataView
Else
Return New DataView()
End If
End Function


Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging
GridView1.DataSource = SortDataTable(GridView1.DataSource, True)
GridView1.PageIndex = e.NewPageIndex
GridView1.DataBind()

End Sub

Protected Sub GridView1_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles GridView1.Sorting
GridViewSortExpression = e.SortExpression
Dim pageIndex As Integer = GridView1.PageIndex
GridView1.DataSource = SortDataTable(GridView1.DataSource, True) GridView1.DataBind()
GridView1.PageIndex = pageIndex
End Sub


I had received an error on Bold line in gridview1_sorting procedure that Unable to cast system.data.dataset to system.data.dataview

Can any body give me solution.
Thanks in advance.

Kartik Rathi
AnswerRe: Sorting in Grid View Pin
postmaster@programmingknowledge.com21-Aug-06 1:20
postmaster@programmingknowledge.com21-Aug-06 1:20 
AnswerRe: Sorting in Grid View Pin
Kartik Rathi21-Aug-06 22:59
Kartik Rathi21-Aug-06 22:59 
QuestionASP.Net Reports Pin
prabhakar dwivedi20-Aug-06 21:06
prabhakar dwivedi20-Aug-06 21:06 
AnswerRe: ASP.Net Reports Pin
Ramasubramaniam21-Aug-06 3:50
Ramasubramaniam21-Aug-06 3:50 
Questionpayment using paypal and 2checkout.com. Pin
Amit Agarrwal20-Aug-06 20:39
Amit Agarrwal20-Aug-06 20:39 
AnswerRe: payment using paypal and 2checkout.com. Pin
Christian Graus20-Aug-06 20:49
protectorChristian Graus20-Aug-06 20:49 
GeneralRe: payment using paypal and 2checkout.com. Pin
Amit Agarrwal20-Aug-06 21:15
Amit Agarrwal20-Aug-06 21:15 
GeneralRe: payment using paypal and 2checkout.com. Pin
Christian Graus20-Aug-06 21:37
protectorChristian Graus20-Aug-06 21:37 
AnswerRe: payment using paypal and 2checkout.com. Pin
seee sharp20-Aug-06 21:46
seee sharp20-Aug-06 21:46 
AnswerRe: payment using paypal and 2checkout.com. Pin
Ramasubramaniam21-Aug-06 4:47
Ramasubramaniam21-Aug-06 4:47 
Questionhow can i Autosave the data using Ajax Pin
Amit Agarrwal20-Aug-06 20:30
Amit Agarrwal20-Aug-06 20:30 
AnswerRe: how can i Autosave the data using Ajax Pin
Christian Graus20-Aug-06 20:52
protectorChristian Graus20-Aug-06 20:52 
GeneralRe: how can i Autosave the data using Ajax Pin
Amit Agarrwal20-Aug-06 21:10
Amit Agarrwal20-Aug-06 21:10 
GeneralRe: how can i Autosave the data using Ajax Pin
Christian Graus20-Aug-06 21:36
protectorChristian Graus20-Aug-06 21:36 
Questionhow to make feature like google Analytics. Pin
Amit Agarrwal20-Aug-06 20:25
Amit Agarrwal20-Aug-06 20:25 
AnswerRe: how to make feature like google Analytics. Pin
Christian Graus20-Aug-06 20:53
protectorChristian Graus20-Aug-06 20:53 
GeneralRe: how to make feature like google Analytics. Pin
Amit Agarrwal20-Aug-06 21:06
Amit Agarrwal20-Aug-06 21:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.