Search
Winners

Win Prizes

Social Presence
Twitter Twitter LinkedIn YouTube Google

Like us on Facebook
Advertisements
Top Forums Author
Fri, 25-Jul-2014 Authors
Murugavelmsc
20
Santosh.Impossible
10
Sekar.C
10
All Time Authors
Jayakumars
4120
Karthikanbarasan
3455
Chvrsri
3140

Latest members | More ...


(Statistics delayed by 5 minutes)

How to Combobox add list of item inside other sub list add item dynamic values add in c# [Resolved]

Rajesh081725
Posted by Rajesh081725 under C# on 12/26/2012 11:33:33 PM | Points: 10 | Views : 1104 | Status : [Member] | Replies : 10


Hi ,
Can u any one know

How to Combobox add list of item inside other sub list add item dynamic values add using if condition in c#

Time is Gold
Thanks & Regards,
Rajesh Kumar,
9962038582.


Posted by: Pavanandey on: 12/27/2012 [Member] Bronze | Points: 25

DropDownList Dll = new DropDownList();
Dll.Items.Add(new ListItem("Pavan","1"));
Dll.Items.Add(new ListItem("Kiran", "2"));
Dll.Items.Add(new ListItem("Ram", "3"));
Dll.Items.Add(new ListItem("Rakesh", "4"));

Adding items to dropdown list

Thanks
Pavan Kumar
Mark Answer if this fits the need

Rajesh081725, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajesh081725 on: 12/27/2012 [Member] Bronze | Points: 25

hi Pavan,
I want to add list of item dynamically and variable array also used.

Time is Gold
Thanks & Regards,
Rajesh Kumar,
9962038582.

Rajesh081725, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 12/27/2012 [Member] Bronze | Points: 25

can you post your code/explain in breif

Thanks
Pavan Kumar
Mark Answer if this fits the need

Rajesh081725, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sandhyab on: 12/27/2012 [Member] Starter | Points: 25

  protected void Page_Load(object sender, EventArgs e)

{
if (!IsPostBack)
{

Dll.DataSource = BindDroDown();
Dll.DataBind();
}
}

private object BindDroDown()
{
ArrayList arMins = new ArrayList();
arMins.Add("00");
arMins.Add("15");
arMins.Add("30");
arMins.Add("45");
return arMins;
}

Rajesh081725, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 12/27/2012 [Member] Bronze | Points: 25

by executing you code and checking drop down at run time these are the values i get in the dropdown list

Dll.Items[0]
Text "00" string
Value "00" string

Dll.Items[1]
Text "15" string
Value "15" string

Dll.Items[2]
Text "30" string
Value "30" string

Dll.Items[3]
Text "45" string
Value "45" string


Thanks
Pavan Kumar
Mark Answer if this fits the need

Rajesh081725, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 12/27/2012 [Member] Bronze | Points: 25

protected void Page_Load(object sender, EventArgs e)
{
DropDownList Dll = new DropDownList();
Dll.DataSource = BindDroDown();
Dll.DataBind();

Dll.Items.Add(new ListItem("Pavan", "1"));
Dll.Items.Add(new ListItem("Kiran", "2"));
}

private object BindDroDown()
{
ArrayList arMins = new ArrayList();
arMins.Add("00");
arMins.Add("15");
arMins.Add("30");
arMins.Add("45");
return arMins;
}

output of dropdown
Dll.Items[0]
Text "00" string
Value "00" string

Dll.Items[1]
Text "15" string
Value "15" string

Dll.Items[2]
Text "30" string
Value "30" string

Dll.Items[3]
Text "45" string
Value "45" string

Dll.Items[4]
Text "Pavan" string
Value "1" string

Dll.Items[5]
Text "Kiran" string
Value "2" string

Thanks
Pavan Kumar
Mark Answer if this fits the need

Rajesh081725, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 12/27/2012 [Member] Bronze | Points: 25

where you can add items from a variable array and also from list

Thanks
Pavan Kumar
Mark Answer if this fits the need

Rajesh081725, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 12/27/2012 [Member] Bronze | Points: 25

Mark answer if this helps you

Thanks
Pavan Kumar
Mark Answer if this fits the need

Rajesh081725, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajesh081725 on: 12/27/2012 [Member] Bronze | Points: 25

Hi Pavan,

First my project is contain dynamic add a list of parent folder or parent forlder with child folder ,This folder name all are display using combobox control.But issues is When i add folder name parent folder only added dynamicall but sub folder not added to list.

How to add Parent item insider sub item .
Example,

rajesh
ram->raju
raja->ram->raj

Time is Gold
Thanks & Regards,
Rajesh Kumar,
9962038582.

Rajesh081725, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 12/31/2012 [Member] Starter | Points: 50

Resolved

Hi Rajesh,
try this sample Code
        private void addParentdirectoryFile(string sourcePath)

{
string[] fileNames = Directory.GetFiles(sourcePath);
foreach (string str in fileNames)
{
comboBox1.Items.Add(str);

}
}

private void addValuesintoCombobox(string sourcePath)
{

foreach (string subFolders in Directory.GetDirectories(sourcePath,"*",SearchOption.AllDirectories))
{
string[] subFolderfileNames = Directory.GetFiles(subFolders);
foreach (string fname in subFolderfileNames)
{
comboBox1.Items.Add(fname);
}
}

}

Call this method :
 addParentdirectoryFile(<Your Directory>);

addValuesintoCombobox(<Your Directory>);

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Rajesh081725, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response


Found interesting? Add this to: