• 操作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 + ",";
                    }
                }

         }

  • 相关阅读:
    杭电1312--Red and Black(Dfs)
    杭电1102--Constructing Roads(简单并查集)
    杭电1969--Pie(二分法)
    最小生成树:HDU1863-畅通工程
    并查集:HDU1213-How Many Tables(并查集最简单的应用)
    并查集:HDU5326-Work(并查集比较简单灵活的运用)
    最小生成树:POJ1251-Jungle Roads(最小生成树的模板)
    图论:HDU2544-最短路(最全、最经典的最短路入门及小结)
    动态规划、记忆化搜索:HDU1978-How many ways
    记忆化搜索:POJ1088-滑雪(经典的记忆化搜索)
  • 原文地址:https://www.cnblogs.com/hqbird/p/1320062.html
Copyright © 2020-2023  润新知