• GridView中DropDownList


    <asp:TemplateField HeaderText="下拉框">
    <ItemTemplate>
    <cc1:MyDropDownList ID="ddlPKG" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlPKG_SelectedIndexChanged" ToolTip='<%# Eval("id") %>' >
    </cc1:MyDropDownList>
    </ItemTemplate>
    </asp:TemplateField>

    protected void gvXyPhone_RowDataBound(object sender, GridViewRowEventArgs e)
    {

    if (e.Row.RowIndex != -1)//注意加上这句就OK
    {

    DropDownList ddlPhoneKG = e.Row.FindControl("ddlPKG") as DropDownList;
    ddlPhoneKG.Items.Add(new ListItem("无", "无"));
    }

     DataRowView drv = (DataRowView)e.Row.DataItem;

    if (drv != null)
    {
    ddlPhoneKG.SelectedValue = drv.Row["kongguan"].ToString();
    }

    }

    //下拉框的值改变

    protected void ddlPKG_SelectedIndexChanged(object sender, EventArgs e)
    {
    DropDownList ddlTKG = (DropDownList)sender;
    string sqlUpdate = "update table1 set kongguan='" + ddlTKG.SelectedValue + "' where id='" + ddlTKG.ToolTip + "'";
    sqlHelp.inUpDelInfo(sqlUpdate);


    //GridView.DataSource = dt2;
    //GridView.DataBind();

    }

  • 相关阅读:
    SpringBoot 日志
    springboot 自动配置
    性能测试步骤
    性能测试与压力测试
    Shell学习八:调用其它shell文件
    Shell学习七:重定向
    Linux mysql服务重启
    Shell学习六:流程控制
    Shell学习五:test参数的使用
    Shell学习四:echo和print输出
  • 原文地址:https://www.cnblogs.com/yubufan/p/5364452.html
Copyright © 2020-2023  润新知