Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Datagrid does not respond to any sorting, dataview filtering, or paging events

Reply
Thread Tools

Datagrid does not respond to any sorting, dataview filtering, or paging events

 
 
Michelle
Guest
Posts: n/a
 
      04-07-2005
This is my third VB.NET forum to try and help me with my problems and several people have failed so I am hoping someone here is a TRUE GURU on datagrids!

I have a datagrid that I bind to a datasource in the page_load event. No problem.
However, when I try to do ANYTHING to its data, nothing works.

Problem 1)

When clicking a dropdown I try to create a dataview based on the value the user selected in the DD and have the filter based on that value....Here is the code.....


Private Sub ddPQMSGrp_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddPQMSGrp.SelectedIndexChanged

Dim strSvcValue As String
strSvcValue = ddPQMSGrp.SelectedItem.Text

Dim dv As New DataView(DataSet151.Tables("Products"))
dv.Table = DataSet151.Products
dv.RowFilter = "[ItemCode (SAP)] = 'strSvcValue'"
DataGridProd.DataSource = dv
DataGridProd.DataBind()

My dataview finds no records matching my filter criteria (which I know exists in the table and the debugger shows that my variable 'strSvcValue' contains the correct value)

Problem 2)
The datagrids property is set to Allow Sorting. My code is as follows...

Private Sub DataGridProd_SortCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEvent Args)
DataGridProd.DataSource = DataSet151.Products.DefaultView
DataSet151.Products.DefaultView.Sort = e.SortExpression
DataGridProd.DataBind()
End Sub

Nothing happens to the datagrid...the data does not change.

Problem 3)
I cannot click on the numbers at the bottom of the datagrid to page through the records. I have the AllowPaging set to true and have selected 30 records to display on each page. My code is as follows.....

Private Sub DataGridProd_PageIndexChanged(ByVal source As System.Object,
ByVal e As System.Web.UI.WebControls.DataGridPageChangedEvent Args)
DataGridProd.CurrentPageIndex = e.NewPageIndex
DataGridProd.DataBind()

End Sub

The data on the datagrid does not change.

Someone, please help me. All of my code basically comes from MS tutorials, my ASP.net class, the Visual Studio help files with sample code, etc. I have even tried using different tables and different databases but every datagrid acts the same (eg, no changes allowed!!) I"M CONSIDERING A SMALL REWARD FOR THE PERSON WHO CAN HELP ME

From http://www.developmentnow.com/g/12_2...gridcontrol.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com
 
Reply With Quote
 
 
 
 
Elton Wang
Guest
Posts: n/a
 
      04-08-2005
Hi Michelle,

About your Questions:

Problem 1)

Change
dv.RowFilter = "[ItemCode (SAP)] = 'strSvcValue'"
to
dv.RowFilter = "[ItemCode (SAP)] = '" + strSvcValue + "'"

Problem 2)

You can try
Dim dv As DataView = DataSet151.Tables
("Products").DefaultView
dv.Sort = e.SortExpression
DataGridProd.DataSource = dv
DataGridProd.DataBind()


Problem 3)

What do you mean 'cannot click on the numbers'?

Anywany, code should be

DataGridProd.CurrentPageIndex = e.NewPageIndex
DataGridProd.DataSource = yourDataSource
DataGridProd.DataBind()

HTH

Elton Wang
http://www.velocityreviews.com/forums/(E-Mail Removed)


>-----Original Message-----
>This is my third VB.NET forum to try and help me with my

problems and several people have failed so I am hoping
someone here is a TRUE GURU on datagrids!
>
>I have a datagrid that I bind to a datasource in the

page_load event. No problem.
>However, when I try to do ANYTHING to its data, nothing

works.
>
>Problem 1)
>
>When clicking a dropdown I try to create a dataview based

on the value the user selected in the DD and have the
filter based on that value....Here is the code.....
>
>
> Private Sub ddPQMSGrp_SelectedIndexChanged(ByVal sender

As System.Object, ByVal e As System.EventArgs) Handles
ddPQMSGrp.SelectedIndexChanged
>
> Dim strSvcValue As String
> strSvcValue = ddPQMSGrp.SelectedItem.Text
>
> Dim dv As New DataView(DataSet151.Tables

("Products"))
> dv.Table = DataSet151.Products
> dv.RowFilter = "[ItemCode (SAP)] = 'strSvcValue'"
> DataGridProd.DataSource = dv
> DataGridProd.DataBind()
>
>My dataview finds no records matching my filter criteria

(which I know exists in the table and the debugger shows
that my variable 'strSvcValue' contains the correct value)
>
>Problem 2)
>The datagrids property is set to Allow Sorting. My code

is as follows...
>
> Private Sub DataGridProd_SortCommand(ByVal source As

System.Object, ByVal e As
System.Web.UI.WebControls.DataGridSortCommandEvent Args)
> DataGridProd.DataSource =

DataSet151.Products.DefaultView
> DataSet151.Products.DefaultView.Sort =

e.SortExpression
> DataGridProd.DataBind()
> End Sub
>
>Nothing happens to the datagrid...the data does not

change.
>
>Problem 3)
>I cannot click on the numbers at the bottom of the

datagrid to page through the records. I have the
AllowPaging set to true and have selected 30 records to
display on each page. My code is as follows.....
>
>Private Sub DataGridProd_PageIndexChanged(ByVal source As

System.Object,
> ByVal e As

System.Web.UI.WebControls.DataGridPageChangedEvent Args)
> DataGridProd.CurrentPageIndex = e.NewPageIndex
> DataGridProd.DataBind()
>
> End Sub
>
>The data on the datagrid does not change.
>
>Someone, please help me. All of my code basically comes

from MS tutorials, my ASP.net class, the Visual Studio
help files with sample code, etc. I have even tried using
different tables and different databases but every
datagrid acts the same (eg, no changes allowed!!) I"M
CONSIDERING A SMALL REWARD FOR THE PERSON WHO CAN HELP ME
>
>
>From

http://www.developmentnow.com/g/12_2005_2_0_0_0/dotnet-
framework-aspnet-datagridcontrol.htm
>
>Posted via DevelopmentNow.com Groups
>http://www.developmentnow.com
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorted DataView, but unsorted datalist when bound to the dataview CodeMonkey ASP .Net 1 02-04-2011 10:55 AM
501 PIX "deny any any" "allow any any" Any Anybody? Networking Student Cisco 4 11-16-2006 10:40 PM
Combining numeric mode paging and nextPreview paging in datagrid Red ASP .Net 1 03-12-2005 11:41 PM
datagrid paging - customising paging style wh1974 ASP .Net 0 01-12-2005 03:48 PM
Server Control - Datagrid Paging - Previous Page events not firing Christopher Pragash ASP .Net Web Controls 0 07-22-2004 02:30 AM



Advertisments