I have some labels in the Masterpage as well as in the child pages. the values in all these labels come from a single DB Query.I want to run this query once so that the labels in the Master and Child gets populated. Is there a way for this?
This is the most simplified version of my question
Here is how I Initialize the public properties in the page_load of Master page (I use viewstate so that other methods can also use these properties)
protected void Page_Load(object sender, EventArgs e)
{
Meeting = bal.GetMeetingByID(MeetingID)[0];//DB QUERY
}
The properties in the page load are as follows
public Meeting1 Meeting
{
set
{
ViewState["Meeting"] = value;
}
get
{
if (ViewState["Meeting"] != null)
return (Meeting1)ViewState["Meeting"];
else
return null;
}
} private int meetingID = -1;
public int MeetingID
{
get
{
if (meetingID == -1)
try
{
meetingID = int.Parse(Request.QueryString["meetingID"]);
}
catch (Exception)
{
Response.Redirect("~/Main.aspx");
}
return meetingID;
}
}
Now in the child page I have
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
return;
DataBindControls();
}
private void DataBindControls()
{
tbMeetingTitle.DataBind();
}
the Meeting.aspx page is like this
<tr>
<td>Meeting Title</td>
<td colspan="3">
<asp:TextBox ID="tbMeetingTitle" runat="server" Width="714px" Text='<%# GetData("MeetingTitle") %>' AutoPostBack="true" ></asp:TextBox></td>
</tr>
I hope now my question is clear.