.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

How will populate dataset from listbox items in asp.net...TIA

Posted By:      Posted Date: October 23, 2010    Points: 0   Category :ASP.Net

More Related Resource Links

How to create a dynamically populated items in a listbox and use it as a navigation?

Hello, I am trying to create navigation inside a listbox menu. I load data from xml to populate a list. Each item in the list box should be a link or button. Then, I create a frame to load xaml pages in it. I tested to load pages employing button control, outside listbox with on click event and it worked well. However, I cannot make it work with list box items. I am hoping to get help from you. Any sample or ideas are highly appreciated. Below is the code:  XML: <?xml version="1.0" encoding="utf-8"?> <Pages> <page id="page01"> <name>Page 01</name> </page> <page id="page02"> <name>Page 02</name> </page> </Pages> C# to initiate a click o n listbox item and get the path to page: private void SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { ListBoxItem lbi = ((sender as ListBox).SelectedItem as ListBoxItem); string itemName = lbi.Content.ToString(); if ( Nav_ListBox.SelectedItem.Equals("Page01" ) ) { ContentFrame.Source = new Uri("Pages/Page01.xaml", UriKind.RelativeOrAbsolute); } } XAML:  <ListBox x:Name="Nav_ListBox" Margin="0" ScrollViewer.HorizontalScrollBarVisibility="Hidden" Background="#FFF2F2F2" ItemTemplate="{DynamicReso

populate dataset from XML obtained from URL

I'm building a website for a client who gets their news from an external source. Their news is in XML and is retrieved via a URL similar to this http://news.domainname.com/LatestNewsXML?custID=1234 I was hoping to grab this news and use it to populate a dataset, could anyone please provide a sample code of how I could do this?  I've developing in .Net 2.0 with C#. Many thanks.

Animate listbox items from ItemTemplate

I want to have a slide-in effect for listbox items, when it's first loaded. I'm using ItemTemplate for listbox items and I coule do the slide-in effect from within the template using RenderTransform and DocubleAnimation. but as the Listbox is vertualized, it does the effect everytime new page of data is loaded in listbox. What I want is to animate the visible items in listbox only when DataContext is changed the first time, like messages list in 'Windows Live Mail' thanks in advance.  

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

Selecting Items in a databound ListBox

Hi All, I'm facing a problem while trying to programatically preselect few items in a databound ListBox. I have set the datasource of the listbox to a DataTable, with required Data and Value member columns. The selection mode of the listbox is MULTIEXTENDED. Platform: .NET  1.1 (not sure if the problem is relevant to other versions) I tried preselecting items in a different ListBox that is not bound to any datasource. I'm able to preselect items using the SetSelected method. Perfect!   How can I achieve the same for a databound ListBox? What am I missing? Any help will be very much appreciated.   Regards, Amirtha

Cannot populate XAML items in template control that in contained within another template control

I have a template control Bookmark, and in MainWindow.xaml, this works just fine: <sdl:Bookmark> <sdl:Bookmark.Bookmarks> <sdl:BookmarkItem Name="test" Extent="-121.89,33.60,-117.09,36.32"> </sdl:BookmarkItem> </sdl:Bookmark.Bookmarks> </sdl:Bookmark> But, I also have a template control Titlebar which inside of its XAML contains a Bookmark control and in MainWindow.xaml, this does NOT work: <sdl:Titlebar x:Name="Titlebar"> <sdl:Titlebar.Bookmark> <sdl:Bookmark.Bookmarks> <!-- Doesn't like this --> <sdl:BookmarkItem Name="test" Extent="-121.89,33.60,-117.09,36.32"> </sdl:BookmarkItem> </sdl:Bookmark.Bookmarks> </sdl:Titlebar.Bookmark> </sdl:Titlebar> I get this error: Error 11 The tag 'Bookmark.Bookmarks' does not exist in XML namespace 'clr-namespace:SDL.ArcGIS.Client.Toolkit;assembly=SDL.ArcGIS.Client.Toolkit'. Line 45 Position 22. C:\Projects\SDL.ArcGIS.Client.Toolkit\SDL.ArcGIS.Client.Toolkit.WPFTestApplication\MainWindow.xaml 45 22 SDL.ArcGIS.Client.Toolkit.WPFTestApplication Bookmark does have a member property in the Titlebar class that is set to the template bookmark in OnApplyTemplate.  I tried making a dependency property for the Bookmark property too, but that didn't

populate a listbox from an xml file.

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;    

Reverse Superscript for Listbox Items in C# windows

I want to show Reverse Super script formate for Listbox Items when i check CheckBox using c# windows forms. thanks ram

trying to loop thru dataset to populate google map properties

I have the following code which works fine, but its hard coded to specific row and columns. And the Labels are just there for visual confirmation on the page, that will not be part of the final setup. How can i loop thru my dataset and populate the marker code for each row in the dataset? DataSet ds = (DataSet)Session["MapData"]; if (ds != null) { GoogleMap1.Latitude = 32.8030; GoogleMap1.Longitude = -96.7699; GoogleMap1.Zoom = 6; GoogleMarker bm = new GoogleMarker(); bm.Latitude = Convert.ToInt32(ds.Tables[0].Rows[0][4]); bm.Longitude = Convert.ToInt32(ds.Tables[0].Rows[0][5]); bm.Text = ds.Tables[0].Rows[0][7].ToString(); GoogleMarker bm1 = new GoogleMarker(); bm1.Latitude = Convert.ToInt32(ds.Tables[0].Rows[1][4]); bm1.Longitude = Convert.ToInt32(ds.Tables[0].Rows[1][5]); bm1.Text = ds.Tables[0].Rows[1][7].ToString(); GoogleMap1.Markers.Add(bm); GoogleMap1.Markers.Add(bm1); Label1.Text = "Not Empty"; } else { Label1.Text = "Is Empty"; } Any help woudl be great. thanks.

How to get values setted in custom items from a ListBox




I have a ListBox which looks like that :

Its DataTemplat is :


<DataTemplate x:Key="IndexDataTemplate">
   <StackPanel Margin="0,0,0,5">
    <TextBlock Height="Auto"

Problem when adding items to a listbox from different threads


I have an application in which different threads add items to a listbox throughout the application's execution (not at startup). But when one of the threads tries to add an item to the listbox, a System.InvanlidOperationException is thrown and the error message is: "The calling thread cannot access this object because a different thread owns it." (In my scenario the "calling thread" is one of the worker threads that add items to the listbox, and the "different thread" is the UI thread.)

So basically I just need a simple way to allow the threads to share the listbox object, or, failing that, some other workaround.

Adding Items to ListBox with animation



I have the following code:

<DataTemplate x:Key="DataTemplate1">
		<EventTrigger RoutedEvent="FrameworkElement.Loaded" SourceName="textBlock">

How to set items from Select Command in Data Source to populate textboxes


I need to know how to get the  items from a Select Command in a Data Source to populate textboxes. For instance in the Select statement below I want to set the textbox for First Name equal to the item in the Select Command highlighted below:


 Protected Sub MHGrid_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MHGrid.SelectedIndexChanged
        Me.Table1.Visible = True

        Me.txtFirstName.Text = (1)

    End Sub


Coloring DropDown ListBox Items


I have a situation where some dropdown listboxes contain some items, then there's a separator line, and then there are more items.  The ones above the separator line reflect the "commonly used items".  To better highlight these I was using code like this to individually color those specfic items:

         foreach (ListItem item in ddList.Items)
          if (item.Value == "-1")
            unAssigned = true;

          if (!unAssigned)
            item.Attributes.Add("style", "color:#5558ff");

This code works fine EXCEPT that once a PostBack occurs then the highlighting disappears.  The items in the dropdown listbox remain (without repopulation) but not the highlighting.

I'm curious why this is happening and whether there's a way for the highlighting to "stick" short of calling this code from the Page_Load event handler every Postback?


Populate a DataSet from an AccessDataSource


This very good piece of code was posted last week as a solution to populating a Data Set with an Objectdatasource.

I am now trying to populate a Data Set from a AccessDataSource.

But replacing the ObjectDataSource with an AccessDataSource doesn't seem to work.

What modifications to the code are needed please !?

Private Function GetDS(ods As ObjectDataSource) As DataSetDim 
ds = New DataSet()
Dim dv = DirectCast(ods.[Select](), DataView)
If dv IsNot Nothing AndAlso dv.Count > 0 Then
Dim dt = dv.ToTable()ds.Tables.Add(dt)
End IfReturn dsEnd Function

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 --

WPF ListBox doesn't Group items if I don't use ItemSource.


WPF ListBox doesn't Group items if I don't use ItemSource.

This code snippet works but I use



private ObservableCollection<

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