弹出问题。。。
GridView里放一个CheckBox代码如下:勾选CheckBox以后,单击Button1,弹出一个窗口,
<asp:TemplateField HeaderText= "选择 ">
<ItemTemplate>
<asp:CheckBox ID= "CheckBox1 " runat= "server " />
</ItemTemplate>
<ItemStyle HorizontalAlign= "Center " VerticalAlign= "Middle " />
<HeaderStyle Height= "20px " HorizontalAlign= "Center " VerticalAlign= "Middle " Width= "10% " />
</asp:TemplateField>
button1的单击事件:
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl( "CheckBox1 ");
if (cbox.Checked == true)
{
Response.Write( " <script> window.open( 'ccxq1.aspx?id= " + Int32.Parse(GridView1.DataKeys[i].Value.ToString()) + " ', ' ', 'width=600,height=500 '); </script> ");
}
}
}
问题,当cbox.Checked == true,不弹出窗口,单击没反应,CheckBox
当cbox.Checked == false,所有的窗口都弹出了,不管你有没勾选CheckBox
数据绑定代码:
private void BindUserData(string yhm)
{
///获取用户数据
///
oalc2 user = new oalc2();
DataSet rr = user.oaccsy(yhm);
///设置GridView的数据源,并绑定数据
GridView1.DataSource = rr;
GridView1.DataKeyNames = new string[] { "id " };
GridView1.DataBind();