操作GRIDVIEW控件绑定取值

 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "deleted")
            {
              
                    int id = DataFormat.ToInt32(e.CommandArgument.ToString());
            
}
        }

 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            //更新部门记录
          Id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
         ChannelName = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtName")).Text;
         
}

protected void GviewOverList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //如果是绑定数据行
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //鼠标经过时,行背景色变
                e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#E6F5FA'");
                //鼠标移出时,行背景色变
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
            }
            if (e.Row.RowIndex != -1)
            {
                //序号
                e.Row.Cells[5].Text == "1900-01-01";

               int id = e.Row.RowIndex + 1 + (GridView1.PageIndex * GridView1.PageSize);
                e.Row.Cells[0].Text = id.ToString();

             }

     }

 

protected void btnsubmit_Click(object sender, EventArgs e)
        {

            //删除ID字符串
            string strDel = string.Empty;
            //页面记录数
            int iRowCount = GviewOverList.Rows.Count;
            for (int i = 0; i <= iRowCount - 1; i++)
            {
                CheckBox cbox = (CheckBox)GviewOverList.Rows[i].FindControl("CheckBox1");
                if (cbox.Checked == true)
                {
                    strDel += GviewOverList.DataKeys[i].Value + ",";
                }
            }

 

     }

转载于:https://www.cnblogs.com/hqbird/archive/2008/10/27/1320062.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值