Загрузка страницы

При нажатии кнопки "Обновить"

The page_load !IsPostBack
Код C# ниже:
Код: Выделить всё
protected void Page_Load( object sender, EventArgs e )
{
if( !Page.IsPostBack )
{
try
{
cblLanguage.DataSource = GenericClass.GetCheckboxList( 4 );
cblLanguage.DataValueField = "keyfield";
cblLanguage.DataTextField = "textfield";
cblLanguage.DataBind();
cblLanguage.EnableViewState = true;
}
catch( Exception ex )
{
litDebug.Text = ex.Message;
}
}
}
protected void btnUpdate_Click( object sender, EventArgs e )
{
litDebug.Text = String.Empty;
try
{
litDebug.Text += "Language Count/viewstate = " + cblLanguage.Items.Count.ToString() + "/" + cblLanguage.EnableViewState.ToString() + "
";
String strLanguages = String.Empty;
foreach( ListItem X in cblLanguage.Items )
{
if( X.Selected )
{
strLanguages += X.Value + ",";
}
else
{
strLanguages += X.Text + ",";
}
}
litDebug.Text += strLanguages;
}
catch( Exception ex )
{
litDebug.Text += ex.ToString();
}
}
static public DataTable GetCheckboxList( int thisMode )
{
DataTable output = new DataTable();
DataSetClass oDs = DataUtils.GetDataSetClass(string.Format("exec sp_getlanguages @mode = {0}", thisMode));
if( oDs != null && oDs.Tables.Count == 1 )
{
output = oDs.Tables[0];
}
return output;
}
Код: Выделить всё
Language
Подробнее здесь: https://stackoverflow.com/questions/798 ... n-postback
Мобильная версия