zoukankan      html  css  js  c++  java
  • 如何在Gridview中的模板DropDownList的change事件中找到index?

    朋友要做个东西,给了需求:在gridview中模板列中有个dropdownlist,如果在dropdownlist改变后,同一行中指定列也跟着改变!

    转载

    具体实现:

    1protected void Drpd_SelectedIndexChanged(object sender, EventArgs e)
    2  {
    3
    4    DropDownList drp = sender as DropDownList; // 触发事件的 DropDownList
    5    GridViewRow row = drp.NamingContainer as GridViewRow; // GridView 当前行 即时在dropdownlist所在容器里 就是行的信息    
    6    row.Style.Add(HtmlTextWriterStyle.BackgroundColor, drp.SelectedValue);
    7    Response.Write(row.RowIndex+1);//获取dropdownlist中选定行的行号.
    8        //Response.Write(String.Format("选中第 {0} 行", row.RowIndex + 1));
    9     DropDownList ddlClass = (DropDownList)sender;
    10     string ClassID = ddlClass.SelectedValue.ToString();//获取Dropdownlist中选定值
    11     //Response.Write(ClassID);
    12}

  • 相关阅读:
    react实现拖拽
    JS实现判断滚动条滚到页面底部并执行事件的方法
    获取地址中的参数 封装在params对象里面
    git常用命令
    Linux定时任务Crontab命令详解
    tars 部署
    tars 问题汇总
    Mac
    http head
    SSL
  • 原文地址:https://www.cnblogs.com/doyourself/p/3138972.html
Copyright © 2011-2022 走看看