I have a DataSource that is bound to my gridview. There is a SelectMethod for this DataSource that calls a stored proc and populates this gridview.
I added a dropdown to filter the gridview. After filtering, I need to repopulate the gridview. Can I create a brand new stored proc based on the selectedValue from the dropdown and call this proc from a method and use this new method as SelectMethod for
the same DataSource? so I can repopulate the gridview based on filtering.
My problem is that when I added filtering, it broke sorting. I was using a DataSource to filter but in order for column sorting to take affect, I was told that I have to use DataSourceID (not DataSource) since the column sorting has been built into the program.
When I was using DataSource, I had to set DataSourceID to null (since I can't use both DataSource and DataSourceID), which fixed my filtering problem but broke column sorting in the gridview. I have to use DataSourceID in order for the column sorting to work.
Hope that makes sense. Coming from an MVC background, this really gets me.....
Thanks,
AM
Use same select method. Manipulate the parameter, query, stored procedure to filter data.
I created a new stored proc, a new select method and attached it to the same ObjectDataSource.
It is giving me the following error:
ObjectDataSource 'odsActions' could not find a non-generic method 'GetAudit' that has parameters: attID, reqID, plnID, scope.
GetAudit is the original method with parameters reqID, plnID, scope. It populates the gridview on page_load.
I added another method GetAuditLogFiltered with parameters: attID, reqID, plnID, scope.
I am not sure why it is looking for attID as parameter in GetAudit. What am I missing?
string SelectedVal = ddlAuditLogFilter.SelectedValue.ToString();
if (!(SelectedVal == "-1"))
{
odsActions.SelectParameters.Clear();
odsActions.TypeName = "Wf.Sparc.DAL.DbAccess";
odsActions.SelectMethod = "GetAuditFiltered";
odsActions.SelectParameters.Add("attID", SelectedVal.ToString());
odsActions.SelectParameters.Add("reqID", reqID.ToString());
odsActions.SelectParameters.Add("plnID", plnID.ToString());
odsActions.SelectParameters.Add("scope", scope);
gvActions.DataBind();
gvActions.Visible = true;
btnActionsExport.Visible = true;
}
else
{
odsActions.SelectParameters.Clear();
odsActions.SelectParameters.Add("reqID", reqID.ToString());
odsActions.SelectParameters.Add("plnID", plnID.ToString());
odsActions.SelectParameters.Add("scope", scope);
odsActions.Select();
}
if (gvActions.Rows.Count == 0)
{
gvActions.Visible = false;
btnActionsExport.Visible = false;
}
archnam
It is giving me the following error:
ObjectDataSource 'odsActions' could not find a non-generic method 'GetAudit' that has parameters: attID, reqID, plnID, scope.
Hi,
The error means ObjectDataSource is confused, try the links below for two possible solutions.
http://kanthu.blogspot.com/2005/10/objectdatasource.html .
Hope it can help you.
Best Regards,
Amy Peng
do your GetAudit method have those parameters?
沒有留言:
張貼留言