Need some advice on a GridView control.

M

Midway

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
 
M

Mikeon

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/2003/Dec/PagingInASPNet.asp
 
M

Midway

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
 
M

Mikeon

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top