gpt4 book ai didi

c# - 我更改了 ObjectDataSource 的 SelectMethod,但它仍然在 GridView 上返回旧值

转载 作者:太空宇宙 更新时间:2023-11-03 16:45:16 25 4
gpt4 key购买 nike

我在我的 ObjectDataSource 中使用了这两个不同的类:

“getColection”和“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 仍显示旧值。类(class)还可以。出了什么问题?

最佳答案

您可能在绑定(bind) ObjectDataSource 后更改 SelectMethod 属性。尝试在您列为快速修复的过程末尾添加 ObjectDataSource1.DataBind();

代码在哪个事件处理程序中运行?

关于c# - 我更改了 ObjectDataSource 的 SelectMethod,但它仍然在 GridView 上返回旧值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6311326/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com