ObjectDataSource下的
            <SelectParameters>
                <asp:QueryStringParameter Name="region_idx" QueryStringField="region_idx" Type="Int32" />
            </SelectParameters>
    protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
    {
        Label4.Text = "插入数据成功!";
        string test=ObjectDataSource2.SelectParameters[0].DefaultValue=e.Values[2].ToString();
    }
他获得一个QueryStringParameter,我的页面上有2个控件 FormView和GridView 
我在
FormView
的ItemInserted事件中设置了SelectParameters的值。 然后GridView可以显示查出来的值但是问题来了,如果我之前传递过SelectParameters的值,URL是这样的
http://localhost/show.aspx?region_idx=2即使我在FormView
ItemInserted事件中设置ObjectDataSource的SelectParameters的值,GridView显示的结果也还是region_idx=2的结果。
我如何控制让ItemInserted事件后ObjectDataSource的SelectParameters值不再被改变

解决方案 »

  1.   

    可能确实没说清楚,我再说下http://localhost/show.aspx?region_idx=2 
    我的ObjectDataSource的SelectParameters绑定的是region_idx的值。在另一个控件FormView1_ItemInserted事件中设置了ObjectDataSource的SelectParameters的值。如何它在后面不再获取region_idx=2 的值
      

  2.   

    如果你绑定了业务对象的某个带参数的方法到ObjectDataSource上,就要设置参数的来源(查询字符串的值,会话变量,页面上控件的属性值),可以用数据源的配置向导