Hi ashOVE,
You can access the controls using the ContentPlaceHolder id.
Check the example.
HTML
Master Page
<html>
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Content Page
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:HiddenField ID="hdnSessionUserpracticeId" runat="server" />
<br />
<asp:TextBox ID="txt_EventTitle" runat="server"></asp:TextBox>
<br />
<asp:DropDownList runat="server" ID="cbo_Practice">
<asp:ListItem Text="7c180b88-57d6-4c38-b47b-d95388742bf3" Value="7c180b88-57d6-4c38-b47b-d95388742bf3" />
<asp:ListItem Text="7c180b88-57d6-4c38-b47b-d95388742bf4" Value="7c180b88-57d6-4c38-b47b-d95388742bf4" />
</asp:DropDownList>
<br />
<asp:DropDownList runat="server" ID="cbo_Practices">
<asp:ListItem Text="ecead95f-dd73-4443-a7c1-0b404d0f1577" Value="ecead95f-dd73-4443-a7c1-0b404d0f1577" />
<asp:ListItem Text="ecead95f-dd73-4443-a7c1-0b404d0f1578" Value="ecead95f-dd73-4443-a7c1-0b404d0f1578" />
</asp:DropDownList>
</asp:Content>
Code
protected void Page_Load(object sender, EventArgs e)
{
// Access the Content page controls.
BindValuesAfterLogin(this.ContentPlaceHolder1.Controls);
}
public void BindValuesAfterLogin(ControlCollection controls)
{
string FinalXML = File.ReadAllText(Server.MapPath("~/XML.txt"));
DataSet ds = new DataSet();
XDocument doc = XDocument.Parse(FinalXML);
XmlReader reader = doc.CreateReader();
ds.ReadXml(reader);
BindFormControls(ds, controls);
}
private void BindFormControls(DataSet ds, ControlCollection controls)
{
foreach (DataTable dt in ds.Tables)
{
var name = dt.TableName;
for (int i = 0; i < dt.Rows.Count; i++)
{
foreach (Control c in controls)
{
switch (name)
{
case "HiddenField":
if (c is HiddenField && ((HiddenField)c).ID == Convert.ToString(dt.Rows[i]["ID"]))
{
((HiddenField)c).Value = Convert.ToString(dt.Rows[i]["Value"]);
}
break;
case "TextBox":
if (c is TextBox && ((TextBox)c).ID == Convert.ToString(dt.Rows[i]["ID"]))
{
((TextBox)c).Text = Convert.ToString(dt.Rows[i]["Text"]);
}
break;
case "Label":
if (c is Label && ((Label)c).ID == Convert.ToString(dt.Rows[i]["ID"]))
{
((Label)c).Text = Convert.ToString(dt.Rows[i]["Text"]);
}
break;
case "CheckBox":
if (c is CheckBox && ((CheckBox)c).ID == Convert.ToString(dt.Rows[i]["ID"]))
{
((CheckBox)c).Checked = Convert.ToBoolean(dt.Rows[i]["Checked"]);
}
break;
case "CheckBoxList":
if (c is CheckBoxList && ((CheckBoxList)c).ID == Convert.ToString(dt.Rows[i]["ID"]))
{
((CheckBoxList)c).SelectedValue = Convert.ToString(dt.Rows[i]["SelectedValue"]);
}
break;
case "RadDateInput":
if (c is RadDateInput && ((RadDateInput)c).ID == Convert.ToString(dt.Rows[i]["ID"]))
{
((RadDateInput)c).SelectedDate = string.IsNullOrEmpty(Convert.ToString(dt.Rows[i]["SelectedDate"])) ? ((RadDateInput)c).SelectedDate : Convert.ToDateTime(dt.Rows[i]["SelectedDate"]);
}
break;
case "RadEditor":
if (c is RadEditor && ((RadEditor)c).ID == Convert.ToString(dt.Rows[i]["ID"]))
{
((RadEditor)c).Content = Convert.ToString(dt.Rows[i]["Content"]);
}
break;
case "RadScheduler":
if (c is RadScheduler && ((RadScheduler)c).ID == Convert.ToString(dt.Rows[i]["ID"]))
{
((RadScheduler)c).SelectedDate = string.IsNullOrEmpty(Convert.ToString(dt.Rows[i]["SelectedDate"])) ? ((RadScheduler)c).SelectedDate : Convert.ToDateTime(dt.Rows[i]["SelectedDate"]);
}
break;
}
}
}
}
}