2010/11/17

SqlDataSource/ObjectDataSource use ViewState

On SqlDataSource's Selecting event:
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
    e.Command.Parameters["UserID"].Value = ViewState["UserID"].ToString();
}

On ObjectDataSource's Selecting event:
protected void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
    e.InputParameters["UserID"] = ViewState["UserID"].ToString();
}

No comments:

Post a Comment