复选列--chenkboxlist
更改选定索引后激发
数据绑定时激发
设置调整属性
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
int n = cbl1.Items.Count;
for (int i = 0; i < n; i++)
{
if (cbl1.Items[i].Selected)
{
string txt = cbl1.Items[i].Text;
string t = txt.Replace(" 请投我一票", "<br>");
Response.Write(t);
}
}
}
{
int n = cbl1.Items.Count;
for (int i = 0; i < n; i++)
{
if (cbl1.Items[i].Selected)
{
string txt = cbl1.Items[i].Text;
string t = txt.Replace(" 请投我一票", "<br>");
Response.Write(t);
}
}
}
数据绑定时激发
protected void CheckBoxList1_DataBound(object sender, EventArgs e)
{
int n = cbl1.Items.Count;
for (int i = 0; i < n; i++)
{
//cbl1.Items[i].Text = cbl1.Items[i].Text + " 请投我一票";
cbl1.Items[i].Text += " 请投我一票";
}
}
{
int n = cbl1.Items.Count;
for (int i = 0; i < n; i++)
{
//cbl1.Items[i].Text = cbl1.Items[i].Text + " 请投我一票";
cbl1.Items[i].Text += " 请投我一票";
}
}
设置调整属性
protected void Button2_Click(object sender, EventArgs e)
{
if (cbl1.RepeatDirection == RepeatDirection.Horizontal)
{
Button2.Text = "给我水平配列";
cbl1.RepeatDirection = RepeatDirection.Vertical;
}
else
{
Button2.Text = "给我垂直排列";
cbl1.RepeatDirection =RepeatDirection.Horizontal;
}
}
{
if (cbl1.RepeatDirection == RepeatDirection.Horizontal)
{
Button2.Text = "给我水平配列";
cbl1.RepeatDirection = RepeatDirection.Vertical;
}
else
{
Button2.Text = "给我垂直排列";
cbl1.RepeatDirection =RepeatDirection.Horizontal;
}
}