复制代码 代码如下:
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);
}
}
}
新闻热点
疑难解答
图片精选