2

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?

4

1 回答 1

0

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

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

于 2011-06-10T20:33:46.990 回答