如何将值设置为下拉列表 [英] How to set value to dropdown list

查看:102
本文介绍了如何将值设置为下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用linkbutton ineach行获取一个gridview。

点击链接按钮编辑后,它正确地将值设置为文本框,但是在下拉列表中它给出错误'对象引用未设置为实例一个对象'

我的代码如下

I take one gridview with linkbutton ineach row.
After clicking on link button edit it sets value to textbox properly but at the Dropdown list it give an error 'Object reference not set to an instance of an object'
My code is as follow

if (e.CommandName.Equals("EditRecord"))
               {
                   GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
                   tbxCode.Text = row.Cells[1].Text;
                   tbxName.Text = row.Cells[2].Text;

                   ddlSection.SelectedItem.Text= row.Cells[3].Text;
                   tbxdesc.Text = row.Cells[4].Text;

                   MultiView1.SetActiveView(ViewAdd);
               }



有人可以帮帮我....

谢谢...


Can anybody please help me....
Thank you...

推荐答案

你检查过row.Cells的值[3] .Text ??
Have you checked the value of row.Cells[3].Text??


亲爱的请先填写你的下拉菜单然后设置下拉值。由于下拉列表为空,它给出错误
Dear please fistly fill your drop down then set the dropdown value. it is giving error because of dropdown list is null


这篇关于如何将值设置为下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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