![](/img/trans.png)
[英]ASP C# Datalist OnItemDataBound event To Change Another Cell Contents
[英]Preserve datalist data on load event in c#
我有包含單選按鈕和復選框的數據列表。 如果我選擇其中一些,然后重定向到另一個aspx頁面。 當我轉到上一頁時,必須選中數據列表中的單選按鈕和復選框。 我已經在會話變量中選擇了數據。 如何使用C#執行此操作。
使用ItemDataBound事件,我將檢索單選按鈕並將其值與您的Session變量進行比較
像這樣的東西:
protected void MyDataList_ItemDataBound(object sender, DataListItemEventArgs e)
{
RadioButton myRadioButton = e.Items.FindControl("myRadioButton") as RadioButton;
if (myRadioButton == null) { }
else
{
if (string.IsNullOrEmpty(Session[myRadioButton.Value])) {}
else myRadioButton.Checked = true;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.