11 Replies - 8847 Views - Last Post: 09 August 2010 - 05:14 AM Rate Topic: -----

#1 programmerjiwa  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 84
  • Joined: 29-June 10

ASP.NET Drop Down List

Posted 02 August 2010 - 06:50 PM

hello everyone....am doing a project in asp.net....
i want make a drop down list....but i can done a simple drop down list...
but i want to split a sentence from table to drop down list...


lets say if i have table column name ="my name is Peter"

i need this sentence in list like:(in 4 rows list)

My
name
is
Peter



give me any idea programmers...

Attached File(s)


This post has been edited by programmerjiwa: 02 August 2010 - 06:51 PM


Is This A Good Question/Topic? 0
  • +

Replies To: ASP.NET Drop Down List

#2 programmerjiwa  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 84
  • Joined: 29-June 10

Re: ASP.NET Drop Down List

Posted 02 August 2010 - 07:11 PM

in simple words i want to split a sentence into drop down list...

e.g: Am Student of Michiegan University


In drop down list:

Am
Student
of
Michiegan
University


Thanks in advance
Was This Post Helpful? 0
  • +
  • -

#3 programmerjiwa  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 84
  • Joined: 29-June 10

Re: ASP.NET Drop Down List

Posted 02 August 2010 - 07:32 PM

Any ideas programmers...?
i using asp.net and sql server
Was This Post Helpful? 0
  • +
  • -

#4 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: ASP.NET Drop Down List

Posted 02 August 2010 - 07:32 PM

Patience young padawan.

Since it appears you want to consistently break on the spaces in the sentence. Then use String.Split to split the sentence into an array of strings. Then load the elements of the array into the DropDownList.
Was This Post Helpful? 0
  • +
  • -

#5 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: ASP.NET Drop Down List

Posted 02 August 2010 - 08:34 PM

And to go along with Jayman, you can bind an array directly to the DropDownList
Was This Post Helpful? 0
  • +
  • -

#6 programmerjiwa  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 84
  • Joined: 29-June 10

Re: ASP.NET Drop Down List

Posted 05 August 2010 - 06:13 PM

hi all..,
am trying to do a drop down list using ASP.NET and SQL server.
the problem is i want data in the column from table(e.g: My Name Is Peter), i need this data come into drop down list like every words in a row.

e.g: -My
-Name
-Is
-Peter

any ideas?
Was This Post Helpful? 0
  • +
  • -

#7 d_rop4nme  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 17
  • View blog
  • Posts: 149
  • Joined: 18-April 10

Re: ASP.NET Drop Down List

Posted 05 August 2010 - 06:54 PM

you would want to use a substring to break up the string on spaces

then


            comboBox1.Items.Clear();
            comboBox1.Items.AddRange(new object[2]
                                    {"",
                                     "Open",
                                     "Partial Payment"
                                    });





However if your information is dynamic, not static like above, you have to figure out how you will use some form of loop to anticipate variations in range, items, etc .

This should be enough for you to get going and figure it out

Good Luck
Was This Post Helpful? 0
  • +
  • -

#8 programmerjiwa  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 84
  • Joined: 29-June 10

Re: ASP.NET Drop Down List

Posted 05 August 2010 - 09:22 PM

How to split a string from database table column into multiple string..and view it into DropDownList using ASP.NET
Was This Post Helpful? 0
  • +
  • -

#9 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: ASP.NET Drop Down List

Posted 05 August 2010 - 09:26 PM

Merged topics. Please do not create the same topic multiple times. You have been given solutions while you have provided nothing.
Was This Post Helpful? 0
  • +
  • -

#10 programmerjiwa  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 84
  • Joined: 29-June 10

Re: ASP.NET Drop Down List

Posted 08 August 2010 - 06:35 PM

hi brothers....
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>

This post has been edited by Jayman: 09 August 2010 - 07:07 AM

Was This Post Helpful? 0
  • +
  • -

#11 programmerjiwa  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 84
  • Joined: 29-June 10

Re: ASP.NET Drop Down List

Posted 08 August 2010 - 07:28 PM

hi all...
i wrote coding for drop down list...
when i select parent drop down list Column"no" i need child drop down list automatically select column"name"

can anyone help me...


dropDownList1-Parent
dropDownList-Child




protected void Page_Load(object sender, EventArgs e)
    {
        //String strData = "";
        //String[] strArray = null;
      
        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())
            {
                dropDownList1.Items.Add(reader["no"].ToString());
                dropDownList.Items.Add(reader["name"].ToString());
            }

          
           



        }


This post has been edited by eclipsed4utoo: 09 August 2010 - 05:10 AM
Reason for edit:: please use the code tags... [code] your code here [/code]

Was This Post Helpful? 0
  • +
  • -

#12 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: ASP.NET Drop Down List

Posted 09 August 2010 - 05:14 AM

when you say, "automatically select", please explain better. What do you want it to automatically select? There seem to be a number of items in the Child DropDownList. Is there a specific one that you want it to select?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1