So ... I have a checkbox on my aspx page
<asp:CheckBox ID="chkHideHighlights" runat="server"
Text="Hide Parameter Hightlights" AutoPostBack="true"
OnCheckedChanged="chkHideHighlights_CheckedChanged"
ViewStateMode="Enabled" />
The change event runs a tiny bit of code to change the name of a stored procedure called w/in the page & to refresh the form holding the values returned from the sp
protected void chkHideHighlights_CheckedChanged(object sender, EventArgs e)
{
if (chkHideHighlights.Checked.Equals(true))
{
sqlGetHTML.SelectCommand = "Customer_Contact_output.SP_EMAIL_PREVIEW_NOCOLOR";
divHighlight.Visible = false;
}
else
{
sqlGetHTML.SelectCommand = "Customer_Contact_output.SP_EMAIL_PREVIEW";
divHighlight.Visible = true;
}
frmEmail.DataBind();
}
The frmEmail control contains data elements populated by calling the SP based on a dropdownlist control change event
I'm desperately trying to find how I can both save the state of the checkbox as well as which SP was set for calling.
I've been trying to mess with ViewState.Add(..) so far I have this:
ViewState.Add("chkHideHightlights", chkHideHighlights.Checked.ToString());
I DO see the values getting written to ViewState ("True" and "False") - btw, it's marked as IsDirty ?
Where I'm stuck is - I'm assuming within the Page_Load I need to check if a value is there & both be able to set (persist) the check box (it always unchecks on ddl change) and (depending on the state of the checkbox) set the SelectCommand on the sql control.
I feel so close - most of my searches come up with .net 2.0 examples :(
Ideas? Help? Thnx in advance.
Aucun commentaire:
Enregistrer un commentaire