J
Jon
Hello all,
I've written the below server control which only half works! When I complie
and include the server control into a project I can get connectionString but
not storedProcedure, it always errors saying it's null, yet the code (seems)
is the same. Can anyone shed any light on this? Thanks:
[DefaultProperty("Text"),
ToolboxData("<{0}:TH_NKServerControl
runat=server></{0}:TH_NKServerControl>")]
public class TH_NKServerControl : System.Web.UI.WebControls.WebControl
{
private string storedProcedure;
private string connectionString;
DataGrid dgrdQuestions;
DataSet dsQuestions;
protected override void CreateChildControls()
{
Controls.Clear();
dgrdQuestions = new DataGrid();
dsQuestions = new DataSet();
dsQuestions = SqlHelper.ExecuteDataset(connectionString, storedProcedure);
dgrdQuestions.DataSource = dsQuestions;
dgrdQuestions.DataBind();
Controls.Add(dgrdQuestions);
}
[Bindable(true), Category("Data"), DefaultValue("")]
public string StoredProcedure
{
get
{
EnsureChildControls();
return storedProcedure;
}
set
{
storedProcedure = value;
EnsureChildControls();
}
}
[Bindable(true), Category("Data"), DefaultValue("")]
public string ConnectionString
{
get
{
EnsureChildControls();
return connectionString;
}
set
{
connectionString = value;
EnsureChildControls();
}
}
}
}
I've written the below server control which only half works! When I complie
and include the server control into a project I can get connectionString but
not storedProcedure, it always errors saying it's null, yet the code (seems)
is the same. Can anyone shed any light on this? Thanks:
[DefaultProperty("Text"),
ToolboxData("<{0}:TH_NKServerControl
runat=server></{0}:TH_NKServerControl>")]
public class TH_NKServerControl : System.Web.UI.WebControls.WebControl
{
private string storedProcedure;
private string connectionString;
DataGrid dgrdQuestions;
DataSet dsQuestions;
protected override void CreateChildControls()
{
Controls.Clear();
dgrdQuestions = new DataGrid();
dsQuestions = new DataSet();
dsQuestions = SqlHelper.ExecuteDataset(connectionString, storedProcedure);
dgrdQuestions.DataSource = dsQuestions;
dgrdQuestions.DataBind();
Controls.Add(dgrdQuestions);
}
[Bindable(true), Category("Data"), DefaultValue("")]
public string StoredProcedure
{
get
{
EnsureChildControls();
return storedProcedure;
}
set
{
storedProcedure = value;
EnsureChildControls();
}
}
[Bindable(true), Category("Data"), DefaultValue("")]
public string ConnectionString
{
get
{
EnsureChildControls();
return connectionString;
}
set
{
connectionString = value;
EnsureChildControls();
}
}
}
}