dropdownlist comboBox with database fill using asp.net Ajax :
aspx :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="jQuery.aspx.cs"
Inherits="jQuery" %>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
// AjaxControlToolKit ADD Refrences :
<%@ Register TagPrefix="ajax" Namespace="AjaxControlToolkit"
Assembly="AjaxControlToolkit" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
</head>
<body>
<form id="form1" runat="server">
<div>
<ajax:ToolkitScriptManager runat="server">
// AjaxControlToolKit Use ScriptManager Add
</ajax:ToolkitScriptManager>
Select Name :
// Ajax COmbo Box
// Ajax COmbo Box
<ajax:ComboBox ID="ajaxCmbName" runat="server"
AutoPostBack="True"
DropDownStyle="Simple"
AutoPostBack="True"
DropDownStyle="Simple"
AutoCompleteMode="SuggestAppend"
CaseSensitive="True"
ItemInsertLocation="OrdinalValue" >
CaseSensitive="True"
ItemInsertLocation="OrdinalValue" >
</ajax:ComboBox>
</div>
</form>
</body>
</html>
SqlConnection Conn = new
SqlConnection(ConfigurationManager.AppSettings["connections"].ToString());
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
// Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
drpName();
}
}
public void drpName()
{
Select = "Select * From Register where Name!='' OR Name!=Null Order
By Name ASC";
da = new SqlDataAdapter(Select,Conn);
da.Fill(ds);
ajaxCmbName.DataSource = ds; // ajax comboBox ID
ajaxCmbName.DataTextField = "Name"; // Name DataFieldName
ajaxCmbName.DataBind();
}
aspx CS:
SqlConnection(ConfigurationManager.AppSettings["connections"].ToString());
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
// Load
{
if (!IsPostBack)
{
drpName();
}
}
public void drpName()
{
Select = "Select * From Register where Name!='' OR Name!=Null Order
By Name ASC";
da = new SqlDataAdapter(Select,Conn);
da.Fill(ds);
ajaxCmbName.DataSource = ds; // ajax comboBox ID
ajaxCmbName.DataTextField = "Name"; // Name DataFieldName
}
// Data Base
No comments:
Post a Comment