如何在asp.net中找到组合框选择的值是string或int [英] How to find the combobox slected value is string or int in asp.net
本文介绍了如何在asp.net中找到组合框选择的值是string或int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
实际上我将整数值和字符串值绑定到组合框值域。现在在cs页面我想在按钮发送事件中找到。如果它是整数意味着我必须执行一个代码,如果它是字符串意味着我必须执行另一个代码....是否可能...
解决方案
查看此
http://msdn.microsoft.com/en-us/library/system.int32.tryparse.aspx [ ^ ]
< blockquote>尝试:
如果(MyComboBox.SelectedItem 是 string )
{
...
}
int s;
if ( int .TryParse(MyComboBox.Text, out s))
// 如果数字
else
// if string
Actually i am binding the integer values and string values to combobox valuefield. now in cs page i want to find in button send event. if it is integer means i have to execute one code and if it is string means i have to execute another code....is it possible...
解决方案
Hi,
Check this
http://msdn.microsoft.com/en-us/library/system.int32.tryparse.aspx[^]
Try:
if (MyComboBox.SelectedItem is string) { ... }
int s; if (int.TryParse(MyComboBox.Text, out s)) //if number else //if string
这篇关于如何在asp.net中找到组合框选择的值是string或int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文