.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

populate a listbox from an xml file.

Posted By:      Posted Date: September 15, 2010    Points: 0   Category :ASP.Net
Hello, I want to populate a listbox with data from an xml file, but i only want to populate it with 2 ElementTagNames (id and name).  each item will have 2 values an id and a name and then on selectedindex i will call another class to do some other tasks based on the id of the item.  I want both of them because i want to display the name and use the ID to do some data manipulation. Here is what i come up with up untill now. I can only get one single ElementTagName per item.  XmlTextReader reader = new XmlTextReader("xmlfile"); XmlDocument XMLdoc = new XmlDocument(); XMLdoc.Load(reader); XmlElement RootNode = XMLdoc.DocumentElement; XmlNodeList nodeList = RootNode.GetElementsByTagName("Name"); int i; for (i = 0; i <= nodeList.Count - 1; i++) { lbox_Choices.Items.Add(nodeList.Item(i).InnerText); } XMLdoc = null;    

View Complete Post

More Related Resource Links

Populate Grid/Listbox depending on the click of checkbox of treeviewitem of treeview in wpf

Hi, I am using your TreeViewWithCheckBoxes example (http://www.codeproject.com/KB/WPF/TreeViewWithCheckBoxes.aspx) in my code. on the basis of checked state in treeview I have to populate a grid. How to go about that. Ex: If Suppose Root Child1 Child1.1 Child1.2 Child2 Child2.1 Child3 Child3.1 Child3.2 is the treeview with checkboxes, and I check, Child1.1 or Root(all treeviewitems selected) node then I have to populate a grid/listbox on the selection basis. Thanks, Manu G

Populate Form Control from xml File -- Easy way--please

Hi All,Is there any easy way to populate control on .net page using xml file? I have below xml file and i need to generate control accordingly using VB language. <dive id="div1" title="genera information" > <fieldgroup id="iduser" title="User Information"> <field id="txtusername" title="UserName" type="Text" maxval="14"> </field> <field id="txtpws" title="passwprd" type="Text" maxval="14"> </fieldgroup> <fieldgroup id="pinfo" title="Personal Info"> <field id="idsex" title="Select Sex" type="Choice"> <option id="1" value="Male"></option> <option id="2" value="Female"></option> <option id="3" value="Other"></option> </field> <field id="idcomb" title="Country" type="Combo"> <option id="1" value="China"></option> <option id="2" value="India"></option> <option id="3" value="Nepal"></op

Populate a Data Flow Task's variables with values from a .dtsConfig file?

I have an SSIS Project to import exchange rates from an XML file into SQL. The project works when I have certain values hard-coded into variables, such as the URL of the XML File, proxy username and passwords etc. I decided to put in a .dtsConfig file, and have it update the values of the variables in the data flow task. So, one of my SSIS Packages in this solution is called ECBDailyRates.dtsx. It contains one control flow, which is a data flow task. The data flow task is a script task which does some XPATH on an XML file, and then provides outputs to an OLE DB Destination, which in turn puts the data into a table in SQL. That much worked before I put in the dtsConfig file. There are a few variables declared inside the data flow task, such as; PricesXMLUriDaily, String ProxyAddress, String ProxyAddressPort, Int32 etc. etc. These are now being updated from the dtsConfig, which is below. It was my understanding that SSIS would run through the config, and update any of the variables as required, and then run my data tasks. However when SSIS runs my script task, none of the variables have been populated, and so it falls over... as it were :) <?xml version="1.0"?> <DTSConfiguration> <DTSConfigurationHeading> <DTSConfigurationFileInfo GeneratedBy="...." GeneratedFromPackageName="dim_Institution" GeneratedFromPackageID="

Populate a listbox in a WinForm apps using C#


Hi there:

 Since I am pretty new to C# winForm appls, I have a dumb question here.

I've drag a ListBox control to a form and want to link this to a query. What I want to achieve is that

when this form is activated , I want to populate this listBox from a query so that user can pick their choice.

   I saw the little triangle icon on the top right side of the listBox control and pick the use data bound items cause I'd like to connect to a query. After this step, I am a lost , don't know what to do.


 Can someone please share his/her experience?






--Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --

Populate ASP Table from Text File


Hey Guys, new developer here. I'm trying to populate a ASP table dynamically. This is what I'm trying to do.

I have table with 1 row and 4 cells. I want to import information from a text file into the various cells. Each line of the text file is what I want to go into each cell.

For example if the text file reads:





I want each line to go into each cell. Is this possible, or will I need to create a SQL Server table and read from that? THANKS!

Need to populate more than two dropdowns from xml file

How to populate more than 2 drop downs using xml file. The dropdowns contains different data.

New To SQL - need to populate a table from a TXT file


i am trying to populate a table from a txt file

this is the query i wrote

USE [Resolution & Ordenances]
INSERT INTO Resolutions (ResolutionID,ResolutionDate,ResolutionDescription)
OPENROWSET('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};

i am getting an error msg

OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".

any idea ?



populate two ddl with one xml file.


I am trying to populate two drop down lists with one xml file...  Here is an example of what I want to do....

xml example...

    <item name="testA" disc="nice">
        <product name="big" price="15.00">
        <product name="small" price="7.50">
    <item name="testB" disc="good">
        <product name="big" price="15.00">
        <product name="small" price="7.50">

I want one drop down list populated with the items.  This I have just a basic xmlDataSource.  My issue is trying to get the second drop down list populated with the products for the selected item.  I hope this is as clear as mud, any help would be appreciated.


File Splitter in .Net

I love to do utility programs in .Net. And this is one of them. As I was playing with JSplit (a free file splitter program), I wondered if I could do it in .Net. The framework supports file operations like reading files in bytes and creating them. It is indeed easy to do file operations in .Net Basics on File operations

Upload Multiple File using JQuery in asp.net

In this article I have explained how to upload multiple files using file upload control. I have used jQuery plugin for uploading multiple files.

I have also explained how to check for file type, file maximum size limit using jQuery & also using server side validation code.

ListBox tricky to set in a DataGrid/GridView

Listboxes are very tricky to set selected items in grid - there is no real nice way to do it. It would have been great if Microsoft included a property that accepts an array or comma separated values - or anything! But they only allow each item in the list to be selected individually. The way to do this in a grid is a bit messy, but it is fairly simple to implement. When a row is created (as per the event), select the items of the listbox as per the datagrid source data:

Creating Excel file from C#

I used below coding for create a excel sheet.I got from on web site.
In below coding there is no problem.Its create the excel file.If i run second time,its ask to overwrite the current excel file.If I said "Yes" then it ok ,but If I select cancel button,its generate the Error message.The exception is

Working with DropDownList and ListBox Controls in ASP.NET

"In my application i am using dropdownlist to display all categories from a table. When the user clicks this control I display all records in that category. Category table also contains column called color.

I wanted display some categories in dropdown list different color and others in different color using ASP.NET."-Anonymous

Upload a File to a SharePoint Document Library - Part I

The following helper class demonstrates a few techniques that allow documents to be uploaded to a SharePoint document library programmatically without using the API or a custom web service. You don't need to specify a document library name, and it will create any folders specified in the URL as required. File meta data will be updated if any properties are passed.

SmtpClient and Locked File Attachments

Got a note a couple of days ago from a client using one of my generic routines that wraps SmtpClient. Apparently whenever a file has been attached to a message and emailed with SmtpClient the file remains locked after the message has been sent. Oddly this particular issue hasn't cropped up before for me although these routines are in use in a number of applications I've built.

How to call an .exe file in .net

Sometimes a developer has to call an EXE from another EXE. While calling EXE there can be a requirement to pass parameter.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend