Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Need some advice on a GridView control.

Reply
Thread Tools

Need some advice on a GridView control.

 
 
Midway
Guest
Posts: n/a
 
      08-28-2006
Hi there,

I am having this problem with a gridview control. what I'm doing is
assigning the gridview's datasource to a objectdatasource which calls a
parameterized stored procedure and that is all fine.

I need to enable the paging and sorting on this gridview, so I have
AllowSorting = True and AllowPaging = True on the gridview properties.

I know since this gridview data source is being bound programatically, I
need to handle the onSorting and PageIndexChanged.

I have been searching the net a lot on how to handle this two but I'm not
having having any luck on it.

Can anybody out there guide to the right information and even give me some
sample code that I could laverage on?

Thanks very much in advance for your help.

Manny
 
Reply With Quote
 
 
 
 
Mikeon
Guest
Posts: n/a
 
      08-28-2006
> I am having this problem with a gridview control. what I'm doing is
> assigning the gridview's datasource to a objectdatasource which calls a
> parameterized stored procedure and that is all fine.
>
> I need to enable the paging and sorting on this gridview, so I have
> AllowSorting = True and AllowPaging = True on the gridview properties.
>
> I know since this gridview data source is being bound programatically, I
> need to handle the onSorting and PageIndexChanged.


If you are using ObjectDataSource, why are you using the DataSource
property and not the DataSourceId property? Using the later, frees you
from having to handle the two events you have mentioned. You just have
to provide methods with right parameters (i.e.: startindex, pagesize
and sort expression) depending on the functionallity you want to get.
Be sure also to check my controls pack at (and related articles on
problems with ObjectDataSource):

http://vaultofthoughts.net/ASPNETControlsPack.aspx

If for some reason you are bound to using the DataSource property
programatically, I'm sure there are a lot of articles on handlig paging
and sorting as for example here:

http://www.c-sharpcorner.com/Code/20...ngInASPNet.asp

--
Michal
http://vaultofthoughts.net

 
Reply With Quote
 
 
 
 
Midway
Guest
Posts: n/a
 
      08-28-2006
Hi there,

Thanks for your reply. I'm kind of new to this kind of development but this
is what I'm trying to do;

the user will choose a item from a dropdown list and depending on the option
the datasource should call a different store procedure depending on the
parametern (i.e. if user chooses to search the field LastName, datasource
should call a stored procedure that expects a parameter @LastName, that is
going to be supplied through a text box, if the user chooses to search on the
firstname, datasource should call a stored procedure that expects a parameter
@FirstName, that will be supplied through a text box, and so on and so on)

One way of doing this I think is changing the stored procedure name
programatically depending on what the user decides to search on.

Some ideas on how to accomplish this please!!???

Thanks very much,

Manny



"Mikeon" wrote:

> > I am having this problem with a gridview control. what I'm doing is
> > assigning the gridview's datasource to a objectdatasource which calls a
> > parameterized stored procedure and that is all fine.
> >
> > I need to enable the paging and sorting on this gridview, so I have
> > AllowSorting = True and AllowPaging = True on the gridview properties.
> >
> > I know since this gridview data source is being bound programatically, I
> > need to handle the onSorting and PageIndexChanged.

>
> If you are using ObjectDataSource, why are you using the DataSource
> property and not the DataSourceId property? Using the later, frees you
> from having to handle the two events you have mentioned. You just have
> to provide methods with right parameters (i.e.: startindex, pagesize
> and sort expression) depending on the functionallity you want to get.
> Be sure also to check my controls pack at (and related articles on
> problems with ObjectDataSource):
>
> http://vaultofthoughts.net/ASPNETControlsPack.aspx
>
> If for some reason you are bound to using the DataSource property
> programatically, I'm sure there are a lot of articles on handlig paging
> and sorting as for example here:
>
> http://www.c-sharpcorner.com/Code/20...ngInASPNet.asp
>
> --
> Michal
> http://vaultofthoughts.net
>
>

 
Reply With Quote
 
Mikeon
Guest
Posts: n/a
 
      08-29-2006
> the user will choose a item from a dropdown list and depending on the option
> the datasource should call a different store procedure depending on the
> parametern (i.e. if user chooses to search the field LastName, datasource
> should call a stored procedure that expects a parameter @LastName, that is
> going to be supplied through a text box, if the user chooses to search on the
> firstname, datasource should call a stored procedure that expects a parameter
> @FirstName, that will be supplied through a text box, and so on and so on)
>
> One way of doing this I think is changing the stored procedure name
> programatically depending on what the user decides to search on.
>
> Some ideas on how to accomplish this please!!???


What about having one stored procedure that accepts all parameters with
some default values?
Than in a select statement you would write something like WHERE
(FirstName = @FirstName OR @FirstName IS NULL)

BTW: If your datasource control is just a layer between your database
and the webform, maybe you should consider using SqlDataSource?


--
Michal
http://vaultofthoughts.net

 
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
GridView Hierarchical View - Gridview in Gridview =?Utf-8?B?bWdvbnphbGVzMw==?= ASP .Net 1 05-09-2006 06:48 PM
Give me some advice about some books of Java programing! yuyazhang Java 14 04-29-2006 11:13 AM
Need some advice Pat Firefox 6 04-17-2005 04:31 PM
Re: I need some advice! Ray Higdon Microsoft Certification 1 11-06-2003 04:32 AM
Re: I need some advice! Mike Brown Microsoft Certification 0 11-02-2003 06:25 AM



Advertisments