这是我的子页面文件和我的母版页文件的部分。我要将 strName 从子页面传递到母版页。我想在子页面中访问此母版页变量,并将子页变量分配给页面加载上或之前的母版页。我经常得到最后选择的值但不是当前值
例如,鉴于记录显示 Mary、John、Peter、
如果我单击 Mary ,则显示 none 如果我单击 Peter,则显示 Mary 如果我舔 John,则显示 Peter
您能否建议并展示如何解决此问题?
以下是我的代码
protected void grdNameSelection_ItemCommand(object sender, GridCommandEventArgs e)
{
RadGrid CurrentGrid = (RadGrid)sender;
GridData GridSource = PageSource.GrdSrcNameSelection;
String a = GridSource.state.ToString();
if (e.CommandName == "SelectCurrent")
{
foreach (GridDataItem item in CurrentGrid.SelectedItems)
{
RowData row = (RowData)GridSource.Current[item.DataSetIndex];
string Name = row.Name;
}
}
}
protected void grdCompanySelection_PreRender(object sender, EventArgs e)
{
UserSession.Instance.CurrentName= Name ;
RadGrid CurrentGrid = (RadGrid)sender;
GridData GridSource = PageSource.GrdSrcCompanySelection;
CommandButtonDisplay(GridSource, CurrentGrid);
}
母版页
protected void Page_init(object sender, EventArgs e)
{
}
protected void Page_Load(object sender, EventArgs e)
{
lblHeader.Text = UserSession.Instance.CurrentName;
if (!Page.IsPostBack)
{ ,,,,