ASP.NET Tip: Create a ViewState Property
public void EditRecord(object recordID)
{
SelectedRecordID = recordID;
// Load record from database and show in control
}
protected object SelectedRecordID
{
get
{
return ViewState["SelectedRecordID"];
}
set
{
ViewState["SelectedRecordID"] = value;
}
}
protected Int32 SelectedRecordID
{
get
{
if (ViewState["SelectedRecordID"] != null)
return Convert.ToInt32(ViewState["SelectedRecordID"]);
else
return -1;
}
set
{
ViewState["SelectedRecordID"] = value;
}
}
No comments:
Post a Comment