如何在模板字段中绑定下拉列表的值 [英] How to bind the value for dropdownlist in Template Field

查看:87
本文介绍了如何在模板字段中绑定下拉列表的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have ttried the below code but i m getting error
            <asp:TemplateField HeaderText="PipNo.">
                <itemtemplate>
                    <asp:DropDownList ID="pipddl" value='<%#Bind("PIP_NO") %>' DataValueField='<%#Bind("PIP_NO") %>' runat="server">
                </itemtemplate>


为此发布解决方案
在此先感谢


post solution for this
thanks in advance

推荐答案

protected void gvResults_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow) //skip header row
    {
        DropDownList ddOpp = (DropDownList)e.Row.Cells[5].FindControl("pipddl");
        ddOpp.Datasource = dt 
ddOpp.DataValueField ="SomeField"
ddOpp.DataTextField ="SomeField"
ddOpp.dataBind();
    }
}


嗨raj,
将下拉列表作为模板字段 [
hi raj,
Bind Dropdownlist as Templatefield[^]


这篇关于如何在模板字段中绑定下拉列表的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆