public class MycustomDS : SqlDataSource
{
[Bindable(true)]
[DefaultValue(true)]
public dynSqlDataSource() : base()
{
this.Load += DynSqlDataSource_Load;
}
public dynSqlDataSource(string _connectionString, string _selectCommand) : base(_connectionString, _selectCommand)
{
}
public dynSqlDataSource(string _provider, string _connectionString, string _selectCommand) : base(_provider, _connectionString, _selectCommand)
{
}
private void DynSqlDataSource_Load(object sender, System.EventArgs e)
{
Type t = this.Page.GetType();
System.Reflection.PropertyInfo pi = t.GetProperty("ViewState", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
StateBag pageViewState = pi.GetValue(this.Page, null) as StateBag;
//Here I get the value of a ViewState that I have on the page where I
//have placed my control
if (System.Web.HttpContext.Current.Session["GlobalIDUsuario"] != null
& Page.Master.FindControl("ASPxComboBoxIDEmpresa") != null
)
{
Int32 IDUsuario = Convert.ToInt32(System.Web.HttpContext.Current.Session["GlobalIDUsuario"]);
string Connection = Tools.GetConnection(((ASPxComboBox)Page.Master.FindControl("ASPxComboBoxIDEmpresa")).Value == null ? 0 : (Int32)((ASPxComboBox)Page.Master.FindControl("ASPxComboBoxIDEmpresa")).Value, IDUsuario);
}
}
}
I have a custom control inherited from an sqldatasource. As you see in the code, I get the value of a ViewState that I have on the page (aspx) where I have the control placed, my question is ... Can I also access a static variable that I have in the .aspx where I have the control ? Thank you
Aucun commentaire:
Enregistrer un commentaire