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"的值
    }

解决方案 »

  1.   

    没明白什么意思,你绑定了这个字段,那么每个项的value就是这个字段的值啊。
    比如DropDownList1.SelectedItem.value
      

  2.   

    int.Parse(DropDownList1.SelectedValue)
      

  3.   

    object obj=DropDownList1.SelectedValue;string value=obj.ToString();
    int intValue=int.Paser(obj);
    string aa=DropDownList1.SelectedValue.ToString();
      

  4.   

     using (OfficeChannel.OfficeChannelDataContext MyCon = new OfficeChannel.OfficeChannelDataContext(ConfigurationManager.ConnectionStrings["OfficeChannelConnectionString_Web"].ConnectionString))
                {
                    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();
            }    }
      

  5.   

    DropDownList1.DataSource = linqTxt; 
    DropDownList1.DataValueField = "BigId";  //id
    this.DropDownList1.DataTextField="BigName";//显示的文本字段
    DropDownList1.DataBind(); 
    //取当前选择的值
    DropDownList1.SelectedValue  //当前选中项的BigId
    DropDownList1.SelectedItem   //当前选中项的BigName
      

  6.   

    DropDownList1.DataValueField = "BigId"; 
    我想要的是这个值
      

  7.   

    int.Parse(DropDownList1.SelectedValue)就是取的这个值
      

  8.   

    在绑定和时候要加上
    DropDownList1.DataTextField = "BigText";
    在获取值的时候 
    DropDownList1.SelectedItem.value就是你所选择值的value了
      

  9.   

    我的值都是GUID 类型的 为什么我跟踪出来的值是 0 1 2出错信息 GUID 应包含带 4 个短划线的 32 位数(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。
      

  10.   

    我的值都是GUID 类型的 为什么我跟踪出来的值是 0 1 2出错信息 GUID 应包含带 4 个短划线的 32 位数(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。
      

  11.   

    7b4c07b4-f329-488e-8d41-9ed6645f248d78bf979f-a63d-4dda-883d-e6f41c66fa19dfc9f246-3aae-4b64-9b2d-f08a6e8181c9