如何根据下拉列表在查询中传递参数. [英] How to pass Parameter in the query according to the dropdown.

查看:53
本文介绍了如何根据下拉列表在查询中传递参数.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据选定的下拉值将参数动态传递给查询.


前任.如果我从dropdwon中选择生日",则像这样传递查询
选择学生的姓名,父亲姓名,生日"并显示在网格视图中..

I want to dynamic passing Parameter according to selected dropdown values into the query.


ex. If I selected "Birthdate" from the dropdwon then passing query like this
"Select Name, FatherName, Birthdate from Student" and display in the gridview..

推荐答案

在这里检查:-

http://forums.asp.net/p/1537443/3739323.aspx [ ^ ]

http://mrbool.com/common-dropdownlist-operation-in-asp- net-and-c/24586 [ ^ ]
check here :-

http://forums.asp.net/p/1537443/3739323.aspx[^]

http://mrbool.com/common-dropdownlist-operation-in-asp-net-and-c/24586[^]


报价:

根据选定的下拉值进入查询

according to selected dropdown values into the query


我不知道您是如何显示出生日期的下拉列表.


I don''t know how you are displaying date of birth is dropdown.

报价:

我想根据选定的下拉值动态传递参数

I want to dynamic passing Parameter according to selected dropdown values


假设您的下拉菜单包含以下值:


Suppose your dropdown contains these values:

Name
FatherName 
Birthdate


您可以尝试以下操作:


You can try this:

SqlCommand cmd = new SqlCommand("Select "+DropDown1.SelectedValue+" from Student");

>

--Amit



--Amit


这篇关于如何根据下拉列表在查询中传递参数.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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