0
在Asp.net 4.0(C#)中,在啓用Paging的網格中,如何在從其他頁面導航時保留文本框的值?在Asp.net 4.0中,在啓用分頁的網格中,如何在從其他頁面導航回來時保留文本框的值?
- 我有一個標籤和文本框數據綁定網格
- 我在一些文本框
- 我導航到另一個頁面中輸入一些值,做同樣的
- 我回到老/前一頁,我在文本框中找不到那些編輯的值。
即使我瀏覽網格中的多個頁面,我也必須保留文本框的值。
請爲我提供一個最簡單的解決方案。
這是代碼:
protected void grdSgnageEntries_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
try
{
DataSet ds = new DataSet();
lblErrorMessage.Text = string.Empty;
int JkpId = 0, LinkLevelId = 0;
if (Convert.ToInt32(ddlSnapShotType.SelectedValue.ToString()) == (int)SnapshotTypes.JackpotHit)
{
JkpId = Convert.ToInt32(ddlJackpotInstances.SelectedValue.ToString());
LinkLevelId = Convert.ToInt32(ddlLevels.SelectedValue.ToString());
}
grdSgnageEntries.PageIndex = e.NewPageIndex;
FillSgnageEntriesGrid(LinkLevelId, JkpId);
grdSgnageEntries.DataBind();
}
catch (FormatException exp)
{
lblErr.Text = "Invalid Date";
grdSgnageEntries.DataSource = null;
grdSgnageEntries.DataBind();
btnSubmit.Visible = false;
}
catch (Exception exp)
{
bc.LogExceptionToDB(exp);
}
}
protected void grdSgnageEntries_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
((TextBox)e.Row.FindControl("txtAmount")).Attributes.Add("onkeypress", "javascript:return MyKeyPress();");
if (((TextBox)e.Row.FindControl("txtAmount")).Text != string.Empty)
{
((TextBox)e.Row.FindControl("txtAmount")).Enabled = false;
btnValidate.Enabled = false;
}
else
{
btnValidate.Enabled = true;
}
}
}
catch (Exception exp)
{
bc.LogExceptionToDB(exp);
}
}
protected void btnGetLevels_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds = bc.getJackpotInstancesForSignageEntry(Convert.ToInt32(ddlLinks.SelectedItem.Value), Convert.ToDateTime(txtEntryDate.Text.ToString()), Convert.ToInt32(ddlSnapShotType.SelectedValue.ToString()), LinkLevelId, JkpId);
Session["gamingDate"] = Convert.ToDateTime(txtEntryDate.Text.ToString());
if (ds.Tables.Count > 1)
{
grdSgnageEntries.Columns[0].Visible = true;
grdSgnageEntries.DataSource = ds.Tables[2];
grdSgnageEntries.DataBind();
grdSgnageEntries.Columns[0].Visible = false;
btnSubmit.Visible = true;
btnValidate.Visible = true;
btnSubmit.Enabled = false;
}
}
我想你只能做到這一點打開彈出一個新頁面,然後關閉它。 – 2012-01-18 10:36:31
@WAP Guy - 你如何瀏覽下一頁,如何點擊按鈕? – Bibhu 2012-01-18 10:42:15
我的意思是網格中的網頁有上一個下一個按鈕 – 2012-01-19 04:10:48