我更改了ObjectDataSource';s SelectMethod,但它仍然返回GridView上的旧值
本文关键字:返回 GridView ObjectDataSource SelectMethod | 更新日期: 2023-09-27 17:58:49
我有两个不同的类要在ObjectDataSource:中使用
"getColection"answers"getLastColectionByUser"
这是我在aspx上的ObjectDataSource。
`
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="getColection"TypeName="HepatiteNegocio.ViewProtocoloCol" SelectCountMethod="getColectionCount"
EnablePaging="True">
<SelectParameters>
<asp:Parameter Name="pWhere" Type="String" />
<asp:Parameter Name="pOrderBY" Type="String" />
<asp:Parameter Name="startRowIndex" Type="Int32" />
<asp:Parameter Name="maximumRows" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>`
如果单选按钮选择的值是"all",则选择方法是"getColection",否则是"getLastColectionByUser",好吗?
`if(radioButton.SelectedValue.Equals("all"))
{
ObjectDataSource1.SelectMethod = "getColection";
ObjectDataSource1.SelectCountMethod = "getColectionCount";
try
{
validation();
ObjectDataSource1.SelectParameters[0].DefaultValue = getWhere();
ObjectDataSource1.SelectParameters[1].DefaultValue = "protocolNumber";
}
catch
{
set an error message
}
}
else
{
ObjectDataSource1.SelectMethod = "getLastColectionByUser";
ObjectDataSource1.SelectCountMethod = "getLastCountColectionByUser";
try
{
validation();
ObjectDataSource1.SelectParameters[0].DefaultValue = getWhere();
ObjectDataSource1.SelectParameters[1].DefaultValue = "protocolNumber";
}
catch
{
set an erron message
}
}
ObjectDataSource1.DataBind();
GridView1.DataBind();`
当我调试时,它运行良好。SelectMethod和SelectCountMethod正在更改,但gridView仍显示旧值。课程还可以。出了什么问题?
您可能在绑定ObjectDataSource之后更改SelectMethod属性。尝试在列出的快速修复程序的末尾添加ObjectDataSource1.DataBind();
。
代码在哪个事件处理程序中运行?