.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

One-click data organisation from a ListBox...?

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :JQuery


I've got a WPF program which, so far, can open up multiple XML files at once and load bits of their information (name) into a listBox with a checkBox beside each list item, this is all in a canvas which is designated as the Load XML canvas. Each of these list items should ideally represent the XML file it's named after. Ideally I want a button which takes all these X number of list items, and loads up X 'data boxes' (which are Grids with text blocks laid out which take strings from different parts of the XML file), where each Grid item is separate from the other ones, and they're all present on another Canvas (for now called the Tracking canvas). I've got code that loads all the information I want into one prototype Grid I've designed, but that only works for one XML file, and it works by referencing its file path in a TextBlock. I need, instead, all the information (or at least the 'index' of which XMLs I want to be used) to come from the list box.

For the functionality of the checkBoxes, I'd want the checked items to appear aligned on the left side on the screen, while the unchecked items appear on the right...

So, basically, I need a button which does these things; 1) looks at the ListBox and sees which XML files it needs to use to grab data from, 2) from the ListBox determines how many Grids it'll need to create on the Tracking canv

View Complete Post

More Related Resource Links

Persist data in a dynamically populated ListBox in a user control


Hi All,

I am trying to persist data in a dynamically populated ListBox in a user control. Here are the details

I have a user control which contains a a listBox and button. On Page_Load of user control I am populating the ListBox control with some values. On Click of button, I am trying to fetch the values which I have selected in ListBox. Though this seems very simple and straight forward I am unable to fetch values.

My Page_Load Function

void Page_Load(object sender, EventArgs e)










My Click Function

Protected Void Button1_Click(object sender, EventArgs e)


       string strValue = listBox.SelectedValue



I have placed brake point at Page_Load and on click function, I am seeing that the moment the breakpoin

Ajax Accordion to load data from client click event


I have a Ajax Accordion control on my page with treeview in Content Template. As the treeview for each pane are big. I am wondering whether I can load the treeview from codebehind only after the pane is selected. I can reuse the code from ItemDataBound of Accordion control.

Data binding a listbox

I'm using VS 2010 and writing a WPF application.  I have a listbox on a form that I want bound to an access database field.  In the code behind I create the usual oledb connection, command and adapter and run a query.  In debug I can see the dataset has 143 items from the database, a single column called "path".  Here's the relevant code:  oleCon.Open(); adpt.SelectCommand = oleComd; adpt.Fill(dtst,"MyTable"); MusicList.DataContext = dtst; MusicList is the listbox.  There's 143 items in the dataset.  When the form loads the listbox is empty.  Here's the xaml for the listbox: <ListBox Grid.Row="1" Height="477" HorizontalAlignment="Left" Margin="7,6,0,0" Name="MusicList" VerticalAlignment="Top" Width="310" Grid.RowSpan="2" Background="#002400" ItemsSource="{Binding Path=path, Mode=OneTime}" DataContext="{Binding}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Path=path}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> At least I know the data is present but why isn't it binding to the listbox? Thanks!  

Export Data From ListBox To Excel

I'm Using C#.NET Is there any examples of how to export data from a ListBox Control to an Excel Spreadsheet in C#.NET? Currently the list box only has 1 column of about 20 records in it.

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

How to refresh the data without having to click on F5?

Hi,My code:private void GetCardDetails() { // Update these variables to values whatever you are storing in your table // If you are storing as CARD NUMBER, update this Card Number Attribute Name to CARD NUMBER string strCardNumberAttributeName = "Credit card number"; // string strCardTypeAttributeName = "1"; string strExpiryDateAttributeName = "Expiry date"; MembershipUser myObject = Membership.GetUser(); string UserID = myObject.ProviderUserKey.ToString(); DataTable dtPaymentDetails = new DataTable(); string queryString = "SELECT tbl_payments.ID, tbl_PaymentDetails.AttributeName, tbl_PaymentDetails.Value, tbl_Payments.PaymentType FROM tbl_Payments INNER JOIN tbl_PaymentDetails ON tbl_Payments.ID = tbl_PaymentDetails.PaymentId WHERE ATTRIBUTENAME IN ('" + strCardNumberAttributeName + "','" + strExpiryDateAttributeName + "') AND (tbl_Payments.UserId = '" + UserID + "') AND (tbl_PaymentDetails.UserId = '" + UserID + "') ORDER BY tbl_Payments.PaymentType DESC"; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(queryString, connection); connection.Open();

Listbox - Temporary suspend Data Binding

Hi. I have a listbox bound to an ADO.NET DataTable (by his DataView) thorough ItemSource property. Whenever I add a new row to DataTable, listbox reflects that change showing an empty item. I want to late the listbox updating until row is committed to database but I can't find the right way. I tried create a Binding using BindingMode.OneTime but it doesn't work. Dim bind As New Binding bind.UpdateSourceTrigger = UpdateSourceTrigger.Explicit bind.Mode = BindingMode.OneTime bind.Source = tblRaccoltePunti.DefaultView lstRaccoltePunti.SetBinding(ListBox.ItemsSourceProperty, bind) I need a way to suspend the DataBinding to manually update listbox when row is committed.

Split a String from a listbox to enter data in a table


Currently, I have a listbox that the selected items are inserted into the database by a string. Now I need to add a new feature that the searches are suppose to be postback individually so the selected values from the listbox need to be inserted into the database individually so the search can work. Is it possible to split an string into separate variables or into an array?

Thanks for your help,



Following is my store procedure and my back code:

<script runat="server">
    Protected Sub insertcompanydata_click1(ByVal sender As Object, ByVal e As EventArgs)

        Dim tobresults2 As String        
        Dim li As ListItem
        Dim myArrayList As ArrayList = New ArrayList()
        Dim strarr() As String
        For Each li In txttoblb.Items
            If li.Selected = True Then
            End If

        strarr = myArrayList.ToArray(Type.GetType("System.String"))
        tobresults2 = String.Join(",  ", strarr)

        Dim txtloblb1 As String
        Dim lin As ListItem
        Dim myArrayList1 As ArrayList = New ArrayList()
        Dim strarr1() As String

Insert/Update data to multiple tables on a single button click


Hi experts,

I need to insert/update data to 3 or more tables on a single button click.What is best method for achieving this?I am using mysql as my DB.

Thanks for your valuable reply in advance.

How to Data bind to a listbox on a wpf usercontrol ?


Hi ,

what i have is a Windows form and in that form i have a elementhost which hosts a wpf usercontrol. On that control is a wpf listbox. In the windows form i have a routine that fetches data form the db.

How can i bind that data to the list box using the "{Binding = ???} attribute in the XAML ?

Currently i bubble up an event and on the event in the windows form i call an action whcih binds to the listbox. is that the correct way to do it



trouble displaying data from selected item in listbox


I have a asp.net web form in which I display registered customers in a listbox. In the listbox I can choose one customer, and click a "Show data"-button. That should display all registered data about the chosen customer in textboxes next to the listbox. This doesn't work and I haven't been able to find where the error lies. Instead of displaiyng the data in the textboxes the error message in:  LabelNoCustomerChosen is displayed. Could it be that the program doesn't find the customer ID? The string that is displayed in the listbox looks like this:

ID Lastname, Firstname

Here's my "Show data"-button click:

protected void ButtonCustData_Click(object sender, EventArgs e)

        string Firstname;
        string Lastname;
        string Street;
        string No;
        int Zip;
        string City;
        string Email;
        string Phone;

        if (ListBoxSearchCust.SelectedItem == null)
            LabelNoCustomerChosen.Visible = tru

Table locked? Can't click into cell and edit data...


 My previous version of sql management studio did not lock me out from a table. Why does this R2 version, after I say open all rows in a table, not allow me to then click on any cell I want to edit data?

It appears just the top 200 rows will allow this. How do I change this setting? What is the purpose of locking like this anyways? 

how to add multiple rows in a data table against a button click event


how to add multiple rows in a data table against a button click event, and then show it in a gridview

Capturing data through a stored procedure as a result of a click event (asp.net)



I am having trouble capturing data as a result of a click event. Basically, I don't know what code to put and where for the click event.

I need to record information from a text box, into a table in Microsoft SQL Server. Any help would be great.

My stored procedure is below:

/****** Object:  StoredProcedure [dbo].[SearchConcept_SP]    Script Date: 10/23/2010 12:17:48 ******/
ALTER PROCEDURE [dbo].[SearchConcept_SP]
@Concept_Name nvarchar(50),
@Keywords char(50)

IF EXISTS(SELECT Concept_Name FROM Concept WHERE Concept_Name = @Concept_Name)
PRINT 'This concept already exists'

INSERT INTO Concept VALUES (@Concept_Name, @Keywords)

Why when I click on title header to sort a GridView, some data disappear?


 Hi there

When I click on my GridView header "End Time" all the rows which contain the string "N/A" disappear.
Here is my code:

protected void GridView2_Sorting(object sender, GridViewSortEventArgs e)
FillDataGridView_JobHistory(ViewState["DateBegin"].ToString(), ViewState["DateEnd"].ToString());

Note: GetSortDirection returns "endTime ASC" or "endTime DESC" and save in ViewState:

ViewState["SortDirection_JobHistory"] = sortDirection;
ViewState["SortExpression_JobHistory"] = column;

Then I fill the DataAdapter and use the ViewState info to sort it:

protected void FillDataGridView_JobHistory(string dateBegin, string dateEnd)
string query = "dbo.GetJobHistory";
DataTable dt = new DataTable();
SqlConnection myConnection = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnString"].ConnectionString);

SqlCommand cmd = new SqlCommand(query, myConnection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@dateBegin", SqlDbType.DateTime));
cmd.Parameters.Add(new SqlParameter("@dateEnd", SqlDbTyp

Insert Data on click event into the database



    I want to insert data in to the database by click on button and input box appears.The data entered in input box must insert into the database , so please help me , i am new to asp.net.....Thanks in advance , and also please suggest me some site that can quickly descirbe me asp.net controls and advance properties ,,,,, actuallly i had created lots sites in php. Now time for asp.net ,,, so please help meSmile

click event on ListBox item


        <Style TargetType="ListBox" x:Key="ImagesBasket" >
            <Setter Property="ItemTemplate">
                            <Border  BorderBrush="Black" BorderThickness="1" CornerRadius="5" Margin="6" Name="border">
                                <Image Source="{Binding URL}"  Stretch="Fill" Width="100" Height="100" >

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