lovelyhelp Posted February 7, 2006 Share Posted February 7, 2006 i trying to build a drop down list in my registeration form. my drop downlist is for job title.I have created my database name userlogin and my table t_classification and i have id and u_classification in my table.my script is smtg like this:---------------------------------------------------------------------------Sub Page_Load() If Not IsPostBack Then conUserLogin = New SqlConnection("server=localhost;UID=userlogin;psw=******;database=userLogin") conUserLogin.Open() cmdSelect = New SqlCommand("select u_classification from t_classification", conUserLogin) ddlClassification.DataSource = dtrclassification ddlClassification.DataTextField = "user_classification" ddlClassification.DataBind() dtrclassification.Close() conUserLogin.Close() End If End Sub<asp:DropDownList ID="ddlClassification" runat="server" Width="86px"></asp:DropDownList>---------------------------------------------------------------------------------the problem is there is no item in my dropdown list when i run it. Link to comment Share on other sites More sharing options...
aspnetguy Posted February 7, 2006 Share Posted February 7, 2006 the variabel you are using as your datascource is not declared (dtrclassification) and ther is no where in your code that the command gets executed.Did you just leave that piece of code out of your post??? If so please post the entire page thanks. Link to comment Share on other sites More sharing options...
lovelyhelp Posted February 11, 2006 Author Share Posted February 11, 2006 the variabel you are using as your datascource is not declared (dtrclassification) and ther is no where in your code that the command gets executed.Did you just leave that piece of code out of your post??? If so please post the entire page thanks.<{POST_SNAPBACK}> the whole things go like this<%@ Page Language="VB" AutoEventWireup="false" CodeFile="newUserRegisteration.aspx.vb" Inherits="newUserRegisteration" %><%@ Import Namespace="System.Data" %><%@ Import Namespace="System.Data.SqlClient" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> Dim conUserLogin As SqlConnection Dim cmdSelect1 As SqlCommand Dim cmdSelect As SqlCommand Dim parmReturnValue As SqlParameter Dim intResult As Integer Dim dtrclassification As SqlDataReader Sub Page_Load() If Not IsPostBack Then Try conUserLogin = New SqlConnection("server=localhost;UID=userlogin;psw=;database=userLogin") conUserLogin.Open() cmdSelect = New SqlCommand("select user_classification from t_classification", conUserLogin) dtrclassification = cmdSelect.ExecuteReader() ddlClassification.DataSource = dtrclassification ddlClassification.DataTextField = "user_classification" ddlClassification.DataValueField = "id" ddlClassification.DataBind() Catch ex As Exception Response.Write(ex.ToString & "<br>") Finally dtrclassification.Close() conUserLogin.Close() End Try End If End Sub ::<asp:DropDownList ID="ddlClassification" runat="server" Width="86px"></asp:DropDownList>:: Link to comment Share on other sites More sharing options...
pr.nimbalkar Posted March 2, 2006 Share Posted March 2, 2006 the variabel you are using as your datascource is not declared (dtrclassification) and ther is no where in your code that the command gets executed.Did you just leave that piece of code out of your post??? If so please post the entire page thanks.<{POST_SNAPBACK}> Hello , you are not executed the Sql command , that's why u are not getting value in Combo.Regards,Prashant... Link to comment Share on other sites More sharing options...
aspnetguy Posted March 2, 2006 Share Posted March 2, 2006 change this ddlClassification.DataSource = dtrclassification to ddlClassification.DataSource = cmdSelect.ExecuteReader(CommandBehavior.CloseConnection) see if that makes a difference Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now