यह लटकती के लिए मेरे सीएस फ़ाइल है:सीएस फ़ाइल में ड्रॉपडाउन सूची में आइटम जोड़ने के लिए कैसे
protected void BindDropDownList()
{
DataTable dt = new DataTable();
string connString = System.Configuration.ConfigurationManager.AppSettings["EyeProject"];
SqlConnection conn = new SqlConnection(connString);
try
{
conn.Open();
string sqlStatement = "SELECT FirstName FROM tbl_UserDetails";
SqlCommand sqlCmd = new SqlCommand(sqlStatement, conn);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlDa.Fill(dt);
if (dt.Rows.Count > 0)
{
DropDownList1.DataSource =dt;
DropDownList1.DataTextField = "FirstName"; // the items to be displayed in the list items
DropDownList1.DataBind();
}
}
catch (System.Data.SqlClient.SqlException ex)
{
string msg = "No Data Found To display in the DropDown List";
msg += ex.Message;
throw new Exception(msg);
}
finally
{
conn.Close();
}
}
By using this one iam getting values of table Firstname values now i want to add one more item Called ALLrecords.
How can i add it.
this is my Aspx file
<div class="label">
Select Name:
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</div>
DropDownList1.Items.Add (नई सूची Item ("सभी रिकॉर्ड")); मैं इसका उपयोग कर रहा हूं। इसके बाद ऑब्जेक्ट्स को ड्रॉपडाउन में प्रदर्शित करने के बाद शेष मूल्य जो डेटाबेस I.e., firstname से प्राप्त हो रहा है। इसे क्लिक करने पर भी ड्रॉपडाउन में दिखाना होगा। –
अपने डेटाबेस मानों के साथ पहले बाध्य ड्रॉपडाउन जैसा आपने अभी किया है और फिर आप जो उपयुक्त हैं उसे जोड़ें या डालें विधि का उपयोग करें। –