如何动态填充下拉列表 [英] How to populate a dropdown list dynamically

查看:89
本文介绍了如何动态填充下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图在dymnamically中填充下拉列表。我正在使用mysql数据库和linq查询从表中检索数据

我不是没有得到如何从表中填充它们。我正在尝试根据此选择过滤数据

我的视图页面包含dhtmlx表单,我正在尝试使用ajax功能检索数据

请给我提供了如何执行此操作的示例

谢谢


I am trying to populate a dropdownlist dymnamically.I am using mysql database and a linq query to retrieve data from the table
Am not not getting how to populate them from table.I am trying to filter the data basing on this selection
My view page contains dhtmlx form and i am trying to retrieve data using ajax functionality
Please provide me samples on how to do this
Thanks

推荐答案

html帮助器上的DropdownList方法具有覆盖以执行此操作:



The DropdownList method on the html helper has an override for doing this:

<![CDATA[<%=Html.DropDownList("CategoryID", (SelectList) ViewData["Categories"], "--Select One--") %>]]>





这是从这个URL的帖子中获取的:它大约是中途下来。



http://forums.asp。 net / t / 1664085.aspx / 1 [ ^ ]


请找到使用storedprocedure(Ajax和jquery)动态绑定下拉列表的代码片段。我没有使用过Linq但是我使用过Sql服务器数据库。希望这会有所帮助。



Aspx页面:

************

<![CDATA [<%@ Page Language =C#AutoEventWireup =trueCodeBehind =MachineCode.aspx.csInherits =SampleApp.MachineCode%>



< html xmlns =http://www.w3.org/1999/xhtml>

< head runat =server> ;

< title>< / title>

< script src =http://ajax.googleapis.com/ajax/libs/jquery/1.11。 1 / jquery.min.js>< / script>

< script type =text / javascript>
Hi, Please find the code snippet to bind the dropdownlist dynamically using storedprocedure (Ajax and jquery).I have not used Linq but I have used Sql server database.Hope this will help.

Aspx Page:
************
<![CDATA[<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MachineCode.aspx.cs" Inherits="SampleApp.MachineCode" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">


(文件).ready(function(){
(document).ready(function () {


这篇关于如何动态填充下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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