|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Need some advice on a GridView control.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 > I am having this problem with a gridview control. what I'm doing is If you are using ObjectDataSource, why are you using the DataSource> 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. 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 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 Show quoteHide quote "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/2003/Dec/PagingInASPNet.asp > > -- > Michal > http://vaultofthoughts.net > > > the user will choose a item from a dropdown list and depending on the option What about having one stored procedure that accepts all parameters with> 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!!??? 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?
objectdataSource case sensitive with parameters??
Exposing an event handler as a control property Don't understand state in WebControls class Page CallBack Add control to TreeView (ASP.NET 2.0) Using Gridview To Export Data To Excel Error (ASP.NET 2.0) Master Page Where in the page lifecycle does validation occur? DetailsView EditItemTemplate CheckBoxList2 bound and Related to CheckBoxList1 Treeview/Treenode oncheck clientside event handler |
|||||||||||||||||||||||