Quantcast
Channel: drop down list
Viewing all articles
Browse latest Browse all 3

drop down list

$
0
0

hi all...
i have done a simple drop down list...and it's working good...
i take "name' from table student...

separately i write coding for split string into multiple...here's my problem.Now i want to add that split into drop down list to split data into drop down list...

please let me know how to add that method into drop down list..Here's the codes i wrote..

 

<code>

//Connection to database and column to split***********************************
protected void Page_Load(object sender, EventArgs e)
{


String strConnection = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Documents and Settings\\jeeva\\My Documents\\Visual Studio 2008\\WebSites\\WebSite2\\App_Data\\tempdb.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";

String strQueryString = "select * from student";

using (SqlConnection sqlConnection = new SqlConnection(strConnection))
{
SqlCommand sqlCommand = new SqlCommand(strQueryString, sqlConnection);
sqlConnection.Open();

SqlDataReader reader = sqlCommand.ExecuteReader();


while (reader.Read())
{
dropDownList.Items.Add(reader["name"].ToString());
}



}



}


//method for split data*********************************
private void splitData (String strData,ref ArrayLit alData)
{
String strTemp = null;
int nCount = 0;

alData = new ArrayList();

foreach (char ch in strData)
{
if (ch != ' ')
strTemp = strTemp + ch;

else if (ch == ' ')
{
if (!String.IsNullOrEmpty(strTemp))
{
alData.Add(strTemp);
strTemp = null;
nCount++;
}
}
}
if (strTemp != null)
alData.Add(strTemp);

}
</code>

 


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles



Latest Images