DataTable dtCtrl = new DataTable();
dtCtrl.Columns.Add("ctrlID");
dtCtrl.Columns.Add("ctrlValue");
ArrayList controlList = new ArrayList();
GetControls(Page.Controls, controlList);
foreach (string str in controlList)
{
if (this.Page.FindControl(str) != null)
{
Control ctrl = Page.FindControl(str);
if (ctrl.GetType().ToString() == "System.Web.UI.WebControls.TextBox")
{
TextBox txtBox = ctrl as TextBox;
if (txtBox.ReadOnly == true && txtBox.Visible == true)
{
DataRow dRow = dtCtrl.NewRow();
dRow["ctrlID"] = txtBox.UniqueID;
dRow["ctrlValue"] = Request[txtBox.UniqueID];
dtCtrl.Rows.Add(dRow);
}
}
}
}
foreach (DataRow drow in dtCtrl.Rows)
{
(Page.FindControl(drow["ctrlID"].ToString()) as TextBox).Text = drow["ctrlValue"].ToString();
}
No comments:
Post a Comment