我更改了 ObjectDataSource 的 SelectMethod 但它仍然在 GridView 上返回旧值
我在我的 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 仍然显示旧值。课程还可以。出了什么问题?
I have this two diferent classes to use in my ObjectDataSource:
"getColection" and "getLastColectionByUser"
This is my ObjectDataSource at aspx.
`
<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>`
If radio button selected value is "all" select method is "getColection" else is "getLastColectionByUser", all right?
`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();`
When I debug it works fine. The SelectMethod and SelectCountMethod are changing BUT the gridView is still showing old values. The Classes are ok. What is going wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能在绑定 ObjectDataSource 后更改 SelectMethod 属性。尝试在作为快速修复列出的过程末尾添加
ObjectDataSource1.DataBind();
。代码在哪个事件处理程序中运行?
You are probably changing the SelectMethod property after the ObjectDataSource is bound. Try adding
ObjectDataSource1.DataBind();
at the end of the procedure you listed as a quick fix.What event handler is the code running in?