using (OfficeChannel.OfficeChannelDataContext MyCon = new OfficeChannel.OfficeChannelDataContext(ConfigurationManager.ConnectionStrings["OfficeChannelConnectionString_Web"].ConnectionString))
{
var linqTxt = from i in MyCon.Class_BigType
select new
{
BigId=i.classBigID,
BigTxt = i.classBigType
};
DropDownList1.DataSource = linqTxt;
DropDownList1.DataValueField = "BigId";
DropDownList1.DataBind(); protected void Button1_Click(object sender, EventArgs e)
{
//怎么获得DropDownList1.DataValueField = "BigId"的值
}
{
var linqTxt = from i in MyCon.Class_BigType
select new
{
BigId=i.classBigID,
BigTxt = i.classBigType
};
DropDownList1.DataSource = linqTxt;
DropDownList1.DataValueField = "BigId";
DropDownList1.DataBind(); protected void Button1_Click(object sender, EventArgs e)
{
//怎么获得DropDownList1.DataValueField = "BigId"的值
}
解决方案 »
- 100分求复杂txt数据导入Oracle的.net程序!!!
- 请高手解决一下?急急急!
- 问个题外话,CSDN里写博客的时候代码格式化
- Grivew 分页不成功!
- 急!!!!!求救中......
- 如何用JAVASCRIPT模拟ASP控件事件
- 帮下小弟
- panel控件定义的问题
- 寻书!各位帮我看看有没有。
- 开发进销存软件是用JAVA还是ASP.NET?JAVA和ASP.NET哪个容易上手吗?主要是这两个都不会,但有很好的编
- 将一个字段绑定在dropdownlist中,字段里存在相同的2个值,只要dropdownlist显示其中一个,应该怎么处理?
- lucene .net ,如何使用,怎么结合数据库的一个表显示数据,能给个数据库表和lucenne的简单例子么
比如DropDownList1.SelectedItem.value
int intValue=int.Paser(obj);
string aa=DropDownList1.SelectedValue.ToString();
{
string DSTID = DropDownList1.SelectedIndex.ToString();//它读出来的不是Guid 出错了
Guid ClassID = new Guid(DSTID);
}
//DropdownList绑定
public void DropDownLintBind()
{
using (OfficeChannel.OfficeChannelDataContext MyCon = new OfficeChannel.OfficeChannelDataContext(ConfigurationManager.ConnectionStrings["OfficeChannelConnectionString_Web"].ConnectionString))
{
var linqTxt = from i in MyCon.Class_BigType
select new
{
BigId=i.classBigID,
BigTxt = i.classBigType
};
DropDownList1.DataSource = linqTxt;
DropDownList1.DataValueField = "BigId";
DropDownList1.DataTextField = "BigTxt";
DropDownList1.DataBind();
} }
DropDownList1.DataValueField = "BigId"; //id
this.DropDownList1.DataTextField="BigName";//显示的文本字段
DropDownList1.DataBind();
//取当前选择的值
DropDownList1.SelectedValue //当前选中项的BigId
DropDownList1.SelectedItem //当前选中项的BigName
我想要的是这个值
DropDownList1.DataTextField = "BigText";
在获取值的时候
DropDownList1.SelectedItem.value就是你所选择值的value了