dropdownlist没有传递选定的值... [英] dropdownlist not passing selected values...

查看:81
本文介绍了dropdownlist没有传递选定的值...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面上有几个下拉列表。在每个ddl中,有一个值列表,然后应该存储所选择的值。由于一些奇怪的原因...只传递了一个ddl值。完全不确定什么是错的。只是为了确保,对于productDDL ...我设置它以便它显示一个productName,但是通过productCode



aspx页面:

i have a few dropdownlists on a page. in each ddl, there is a list of values and the selected values are then supposed to be stored. for some oddball reason...only one of the ddl values are being passed. completely unsure of what's wrong. just to be sure, for productDDL...i have it set so that it DISPLAYS a productName, but PASSES the productCode

aspx page:

<asp:DropDownList ID="soooDDL" runat="server">
            <asp:ListItem Value="1">happy</asp:ListItem>
            <asp:ListItem Value="2">glad</asp:ListItem>
            <asp:ListItem Value="3">sad</asp:ListItem>
            <asp:ListItem Value="4">mad</asp:ListItem>
        </asp:DropDownList>

<asp:DropDownList ID="frDDL" runat="server">
            <asp:ListItem Value="CT">CT</asp:ListItem>
            <asp:ListItem Value="JT">JT</asp:ListItem>
            <asp:ListItem Value="F">F</asp:ListItem>
        </asp:DropDownList>

<asp:DropDownList ID="productDDL" runat="server" DataSourceID="productDS"

            DataTextField="productName" DataValueField="productCode">
        </asp:DropDownList>
        <asp:SqlDataSource ID="productDS" runat="server"

            ConnectionString="<%$ ConnectionStrings:connSTR %>"

            SelectCommand="SELECT * FROM [productTable]"></asp:SqlDataSource>
        <asp:Label ID="productCodeLabel" runat="server" Text="Label"></asp:Label>
</pre>





i有一个存储值的busObj。 />
到目前为止...唯一一个似乎存储任何内容的是frDDL,它发送ctjtf



i have a busObj that stores the values.
so far...the only one that seems to store anything is the frDDL one which sends the ctjtf

private string sooo_BO;
private string ctjtf_BO;
private string productCode_BO;

public string setodosou
    {
        get
        {
            return sooo_BO;
        }
        set
        {
            value = sooo_BO_BO;
        }
    }
public string ctjtf
    {
        get
        {
            return ctjtf_BO;
        }
        set
        {
            ctjtf_BO = value;
        }
    }
public string productCode
    {
        get
        {
            return productCode_BO;
        }
        set
        {
            productCode_BO = value;
        }
    }







这似乎适用于ctjtf ...我已经尝试了完全相同的代码并且......其他两个没有...




this seems to work for ctjtf...i've tried the EXACT same code and...nothing for the other two

lBO.ctjtf = frDDL.SelectedValue.ToString();



这个,正如我所说的......将适当的价值发送到busObj





专注于soooDDL ......

尝试1:


this, as i said...sends the proper value through to the busObj


focusing on just the soooDDL...
attempt 1:

lBO.setodosou = soooDDL.SelectedValue;



in local ...我看到字符串的空值即使我选择了一个产品





attempt2:


in local...i see null value for the string even though i selected a product


attempt2:

lBO.setodosou = soooDDL.SelectedValue.ToString();



in local ... null值...再次,这是我用于ctjtfDDL的完全相同的东西,我可以看到一个工作正常。肯定存储在内存中的正确值。



attempt3:


in local...null value...again, this is the exact same thing i used for the ctjtfDDL and i can see that one worked just fine. there's definitely the proper value stored in memory.

attempt3:

lBO.setodosou = soooDDL.SelectedItem.Value;



仍然......空值,这里有什么奇怪的,当我写出这一行时,如果我将鼠标悬停在代码隐藏中的.Value上,我可以看到值是我选择的,但由于某种原因......变量未被传递


still...null value and what's weird here is when i write out the line, if i hover over ".Value" in codebehind, I can see that the "value" is what I selected, yet for some reason...the variable isn't being passed

推荐答案

ConnectionStrings:connSTR%>

SelectCommand = SELECT * FROM [productTable] > < / asp:SqlDataSource >
< asp:Label ID = productCodeLabel runat = server 文字 = 标签 > < / asp:标签 >
< / pre >
ConnectionStrings:connSTR %>" SelectCommand="SELECT * FROM [productTable]"></asp:SqlDataSource> <asp:Label ID="productCodeLabel" runat="server" Text="Label"></asp:Label> </pre>





i有一个存放值的busObj。

到目前为止...唯一一个似乎存储任何内容的是frDDL,它发送ctjtf



i have a busObj that stores the values.
so far...the only one that seems to store anything is the frDDL one which sends the ctjtf

private string sooo_BO;
private string ctjtf_BO;
private string productCode_BO;

public string setodosou
    {
        get
        {
            return sooo_BO;
        }
        set
        {
            value = sooo_BO_BO;
        }
    }
public string ctjtf
    {
        get
        {
            return ctjtf_BO;
        }
        set
        {
            ctjtf_BO = value;
        }
    }
public string productCode
    {
        get
        {
            return productCode_BO;
        }
        set
        {
            productCode_BO = value;
        }
    }







这似乎适用于ctjtf ...我已经尝试了完全相同的代码并且......其他两个没有...




this seems to work for ctjtf...i've tried the EXACT same code and...nothing for the other two

lBO.ctjtf = frDDL.SelectedValue.ToString();



这个,正如我所说的......将适当的价值发送到busObj





专注于soooDDL ......

尝试1:


this, as i said...sends the proper value through to the busObj


focusing on just the soooDDL...
attempt 1:

lBO.setodosou = soooDDL.SelectedValue;



in local ...我看到字符串的空值即使我选择了一个产品





attempt2:


in local...i see null value for the string even though i selected a product


attempt2:

lBO.setodosou = soooDDL.SelectedValue.ToString();



in local ... null值...再次,这是我用于ctjtfDDL的完全相同的东西,我可以看到一个工作正常。肯定存储在内存中的正确值。



attempt3:


in local...null value...again, this is the exact same thing i used for the ctjtfDDL and i can see that one worked just fine. there's definitely the proper value stored in memory.

attempt3:

lBO.setodosou = soooDDL.SelectedItem.Value;



仍然......空值,这里有什么奇怪的,当我写出这一行时,如果我将鼠标悬停在代码隐藏中的.Value上,我可以看到价值是我选择的,但由于某种原因......变量没有被传递


still...null value and what's weird here is when i write out the line, if i hover over ".Value" in codebehind, I can see that the "value" is what I selected, yet for some reason...the variable isn't being passed


你注意到了



did you notice

public string setodosou
    {
        get
        {
            return sooo_BO;
        }
        set
        {
            value = sooo_BO_BO;
            // Should be 
            sooo_BO = value;
        }
    }


这篇关于dropdownlist没有传递选定的值...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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