Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 下拉式ASPX如何从列表中查询_C#_Webforms - Fatal编程技术网

C# 下拉式ASPX如何从列表中查询

C# 下拉式ASPX如何从列表中查询,c#,webforms,C#,Webforms,我正在尝试从数据库中选择唯一的ID,并将其放入下拉菜单中的a列表中。我知道这似乎很容易,但我有点糊涂。你能帮我吗。我试着以某种方式询问列表,但我不知道它是否好,然后我试着把它放在我的asp是这样的: ID: <asp:DropDownList ID="ProdtID" runat="server"></asp:DropDownList> ID: 问题是它没有显示任何东西 IDataReader ProductId = null; int n = 300; for

我正在尝试从数据库中选择唯一的ID,并将其放入下拉菜单中的a列表中。我知道这似乎很容易,但我有点糊涂。你能帮我吗。我试着以某种方式询问列表,但我不知道它是否好,然后我试着把它放在我的asp是这样的:

ID: <asp:DropDownList ID="ProdtID" runat="server"></asp:DropDownList>
ID:
问题是它没有显示任何东西

IDataReader ProductId = null;

int n = 300;

for (int i = 0; i < n; i++)
{
    string getProductName = "";
    NameValueCollection coll = HttpContext.Current.Request.Form;
    objProducts.productname = coll[ProdtID.UniqueID];
    ProductId = this.objProducts.getProductsData();
    this.objUtil.selectBindDs(ProdtID, ProductId, "PickPN", "PickPN_id");
    //Response.Write(NameValueCollection.[0].Value);
    ProdtID.DataSource = ProductID;
    ProdtID.DataBind();
}
IDataReader ProductId=null;
int n=300;
对于(int i=0;i
在您的aspx中

ID: <asp:DropDownList ID="ProdtID" runat="server"></asp:DropDownList>

关闭:如果您对它有任何影响,请尽快删除web表单。
protected void Page_Load(object sender, EventArgs e)
    {
        //https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-3.0/14atsyf5(v=vs.85)
        ProdtID.Items.Add(new ListItem("Carbon", "C"));
        ProdtID.Items.Add(new ListItem("Oxygen", "O"));
    }