获得空值如何解决它.... [英] Getting Null Value How to Solve It....

查看:89
本文介绍了获得空值如何解决它....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai先生,





我在gridview.i中创建动态下拉列表想要从下拉列表中检索选定的值。但我得到null值。请解决我的问题

Hai sir,


I am creating dynamic dropdown in inside gridview.i want to retrive selected value from dropdown. But i get null value.Please solve my problem

 for (int i = 0; i < GridView2.Rows.Count; i++)
{
    DropDownList box = (DropDownList)GridView2.Rows[i].Cells[1].FindControl("murali" + (i + 1).ToString());
}  



我在box获得空值


I get null value at "box"

推荐答案

你这样做了错误! FindControls 查找控件,而不是控件中的任何数据。它通过控件的名称来寻找一些控件。您的结果只是告诉您没有该名称的控件。当然,你从来没有创造过一个;因为这只是数据的一部分。



您可以使用 DropDownList.Items.IndexOf 代替。 />


-SA
You are doing it so wrong! FindControls looks for control, not for any data in control. It looks for some control by control''s name. You result just tells you there is no control with that name. Naturally, you never created one; as this is just part of the data.

You can use DropDownList.Items.IndexOf instead.

—SA


这篇关于获得空值如何解决它....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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