gridview中如何给FooterTemplate中的DropDownList控件赋值? ASP.net C#:gridview中如何给FooterTemplate中的DropDownList控件赋值?写在哪个事件里?请高手指教。谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你想怎样赋值?可以在编辑模板的时候用Bind来绑定字段,也可以用gridview.findcontrol(id)方法来操作 我在Page_Load中用以下代码,老是报错,是怎么回事? GridViewRow footrow = GridView1.FooterRow; DropDownList ddl = (DropDownList)footrow.FindControl("DropDownList1"); ddl.Items.Add("aaaaaa");(我用的是asp.net 2.0 ) protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType = DataControlRowType.Footer) { DropDownList ddl = (DropDownList)e.Row.FindControl("DropDownList1"); } } 谢谢楼上的,这样是可以,不过呢,我这个DropDownList 是设置成了AUTOPOSTBACK的,后面有个DropDownList 要根据前面的DropDownList 动态选值的,所以需求比较麻烦。不过,还是谢谢你。MS的这些控件真他的难用还是以前ASP年代用纯粹的手写方便点。 没什么麻烦的。给你DropDownList1 加上selectedindexchange事件然后在事件里边找到DropDownList2............ protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { //int index=((GridViewRow)(((DropDownList)sender).Parent.Parent)).RowIndex; ((DropDownList)GridView2.FooterRow.FindControl("DropDownList2")).SelectedValue = ((DropDownList)sender).SelectedValue; } 指定的参数已超出有效值的范围。 【重新开贴】关于一个审核流程的思路 datatable如何一一对应导入到数据库中 GridView中模板中的文本框批量数据更改的问题!(有点像CSDN结贴的那种效果) 有人介绍下asp免费空间不 求可以上传n个附件的代码 打开模态窗口并传参 大侠帮忙啊。。。。开100分!!!!!一个很简单的问题 怎样在客户端激发JSCRIPT或VBSCRIPT程序? 请教怎么对asp.net工程进行打包呢? 有关 ASP.NET + Access 网站的几个问题.望各位大虾帮忙!在线等!!! 大家快来看看,这段代码
DropDownList ddl = (DropDownList)footrow.FindControl("DropDownList1");
ddl.Items.Add("aaaaaa");(我用的是asp.net 2.0 )
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType = DataControlRowType.Footer)
{
DropDownList ddl = (DropDownList)e.Row.FindControl("DropDownList1");
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
//int index=((GridViewRow)(((DropDownList)sender).Parent.Parent)).RowIndex;
((DropDownList)GridView2.FooterRow.FindControl("DropDownList2")).SelectedValue = ((DropDownList)sender).SelectedValue;
}