日期:2014-05-17 浏览次数:20389 次
protected void Button2_Click(object sender, EventArgs e)
{
Button bt = sender as Button;//将sender这个object对象转换成button对象,as转换,获取事件发送者button
if (bt != null)
{
///Control.NamingContainer属性获取对服务器控件的命名容器的引用,利用button控件的NamingContainer获取GridViewRow(当前行)
GridViewRow row = bt.NamingContainer as GridViewRow;
///FindControl返回的是一个control类型的控件
///获取第一列Control控件的集合转换成checkBox类型的控件,
CheckBox cb = row.Cells[0].FindControl("ck") as CheckBox ;
if (cb.Checked)
{
///获取选中checkbox的值
string id=GridView1.DataKeys[GridView1 .SelectedIndex ].Value.ToString();
string constr = ConfigurationManager.ConnectionStrings["Conn"].ToString();
OleDbConnection conn = new OleDbConnection(constr);
conn.Open();
string s = "select * from D_SheList where [ID]=id";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(s, conn);
da.Fill(ds);