Zrlhappy的博客
                               从今天起, 做一个幸福的人
                                    喂马, 劈柴, 周游世界
                                    从今天起, 关心粮食和蔬菜
                                    我有一所房子, 面朝大海, 春暖花开
                                    给每一条河每一座山取一个温暖的名字
                                    我也愿面朝大海, 春暖花开……
 //如何在.cs文件中,引用GridView中添加的转换为模版的列的值。

1.  首先在.aspx文件中给转换为控件的新增列绑定字段,然后才能在.cs文件中调用它的值。

2.  .cs文件中,用    ((LinkButton)sender).CommandArgument.ToString()    这个语句来调用带过来的值。

3.  LinkButton1_Click函数的写法如下:

     protected void LinkButton1_Click(object sender, EventArgs e)

      {

        SqlConnection myconn;

        myconn = new SqlConnection(ConfigurationManager.ConnectionStrings["JlyConnectionString"].ConnectionString);

        myconn.Open();

        SqlCommand myCMD = new SqlCommand("update ClientTable set IsDelete=1 where ClientID=" + ((LinkButton)sender).CommandArgument.ToString(), myconn);

        SqlDataReader myReader = myCMD.ExecuteReader();

 

        //GridView的数据源重新邦定一下。相当于刷新。

        string res = "SELECT ClientID, ClientName, ClientPassword, ClientTrueName, ClientEmail, ClientSex, ClientAge, ClientIntro, ClientMemo, IsPass, IsDelete FROM ClientTable WHERE (IsPass = 0) and (IsDelete=0) Order by [ClientID] Desc";

        SqlDataSource1.SelectCommand = res;

        GridView1.DataSourceID = "SqlDataSource1";

        GridView1.DataBind();

  }


posted on 2006-03-14 14:52  zrlhappy  阅读(518)  评论(0编辑  收藏  举报