项目模板中的下拉菜单中的调用值 [英] call value inside dropdown when in item Template

查看:54
本文介绍了项目模板中的下拉菜单中的调用值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生您好,

我想问一问我在Itemtemplate字段中使用了dropdownlist的那个网格中有一个网格,我做了一个功能,即

Hello sir,

I would like to ask that there is a grid in that grid I have taken dropdownlist in Itemtemplate field,I made one function i.e.

filldropdown()
{
DataTable dt=new DataTable();
dt=clss.filldrop();
dropdownlist.datasource=dt;
dropdownlist.databind();
}


我无法填写下拉列表,因为我想在函数中调用ID以从数据库中插入值,即在ItemTemplate内部.

请帮助我纠正我的问题,即如何调用gridview的ItemTemplate内部的下拉菜单ID.

请指导我.

在此先感谢您.


I am unable to fill dropdown beacuse The ID I want to call in the function to insert values from my database i.e. inside ItemTemplate.

Please help me to rectify my problem, how I can call ID of dropdown that is inside ItemTemplate of gridview.

Please guide me.

Thanks in advance.

推荐答案

只要您在控件的项目/替代项模板中拥有控件,就无法直接访问控件
您需要通过将方法FindControl()与主控件一起使用来提取内部控件.

您的情况就是这样


whenever you have control within a control''s item/alternate-item template you can''t access control directly
you need to extract inner control by using method FindControl() with main control.
i.e.
in your case it will be like this


DropDownList list = (DropDownList) myGrid.FindControl("ddlName");
list.DataSource = dt;
list.DataBind();


这篇关于项目模板中的下拉菜单中的调用值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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