选择checkbox时,文本才可以被编辑
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace WebApplication2
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
sql.oracl();//数据库连接
DataSet ds = sql.user();//获取数据
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
TableRow row = new TableRow();
TableCell cellhead = new TableCell();
TableCell cellcontent = new TableCell();
CheckBox ck = new CheckBox();//复选框
TextBox tb = new TextBox();//文本框
ck.ID ="ck"+ ds.Tables[0].Rows[i]["f_userid"].ToString();//给ID
ck.Text = ds.Tables[0].Rows[i]["f_username"].ToString();//设置文本
tb.ID = "tb" + ds.Tables[0].Rows[i]["f_userid"].ToString();//设置ID
tb.Enabled = false;//复选框没有选的时候文本框不可用
ck.Width=200;//设置宽度
ck.Checked = false;//默认设置
ck.AutoPostBack = true;
ck.CheckedChanged += ck_CheckedChanged;//添加事件
cellhead.Controls.Add(ck);
cellcontent.Controls.Add(tb);
cellhead.HorizontalAlign = HorizontalAlign.Right;
cellcontent.HorizontalAlign = HorizontalAlign.Left;
row.Cells.Add(cellhead);
row.Cells.Add(cellcontent);
this.Table1.Rows.Add(row);
}
}
void ck_CheckedChanged(object sender, EventArgs e)
{
该怎么写?
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}