
復制代碼 代碼如下:
View Code
protected void Button1_Click(object sender, EventArgs e)
{
Button button = (Button)sender;
if (FindControl("DataListConstellation") == null) return;
DataList dlconstellation = (DataList)FindControl("DataListConstellation");
foreach (DataListItem dli in dlconstellation.Items)
{
if (dli.FindControl("RadioButtonSelect") == null) return;
RadioButton rb = (RadioButton)dli.FindControl("RadioButtonSelect");
if (rb.Checked)
{
LabelSelectedResult.Text = string.Format("你執行銨鈕'{0}',選擇行的索引是:{1}; 主鍵值是:{2}", button.Text, dli.ItemIndex.ToString(), dlconstellation.DataKeys[dli.ItemIndex].ToString());
break;
}
else
{
LabelSelectedResult.Text = string.Format("你執行銨鈕'{0}',沒有選擇任何一行。", button.Text);
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Button button = (Button)sender;
DataList dlconstellation = (DataList)FindControl("DataListConstellation");
for (int i = 0; i < dlconstellation.Items.Count; i++)
{
RadioButton rb = (RadioButton)dlconstellation.Items[i].FindControl("RadioButtonSelect");
if (rb.Checked)
{
LabelSelectedResult.Text = string.Format("你執行銨鈕'{0}',選擇行的索引是:{1}; 主鍵值是:{2}", button.Text, i.ToString(), dlconstellation.DataKeys[i].ToString());
break;
}
else
{
LabelSelectedResult.Text = string.Format("你執行銨鈕'{0}',沒有選擇任何一行。", button.Text);
}
}
}
|
新聞熱點
疑難解答
圖片精選