w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Save listBox item to another listBox which is in another class
Bind both view elements (the elements you want to be "connected" with each other) to the same ViewModel collection. So if one writes inside the text box, change propagated to the ViewModel collection, so notification spreads among subscribers, so to another view too.

Categories : C#

Save multiple same named fields to database PHP
$cols = $_POST['col']; $EvenementID = mysql_real_escape_string($_POST['evenementid']); foreach($cols as $col) { $Ticketnaam = mysql_real_escape_string($col['ticket']); $Aantal = mysql_real_escape_string($col['aantal']); $Prijs = mysql_real_escape_string($col['prijs']); $sql = "INSERT INTO tbl_Tickets (EvenementID, Ticketnaam, Aantal, Prijs) VALUES('".$EvenementID ."', '{$Ticketnaam}', '{$Aantal}', '{$Prijs}')"; $res = mysql_query($sql);//This will execute count($cols) number of times } You need to move the mysql_query($sql) inside the loop, otherwise it will execute the last iteration of the foreach loop only.

Categories : PHP

Listbox item as Listbox should clear the selection of its item when other item's item is selected?
You can explicitly null the SelectedItem whenever the ListBox loses focus, i.e you have to handle the LostFocus event. You could add the event handler to the ListBox and handle the event in the code behind. XAML Change: <ListBox x:Name="lstMsgs" HorizontalAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Hidden" HorizontalContentAlignment="Stretch" ItemsSource="{Binding MessageList}" SelectedItem="{Binding DataContext.SelectedMessage,Mode=TwoWay,ElementName=me}" Background="Transparent" BorderThickness="0" LostFocus="lstMsgs_LostFocus"> Code Behind: private void lstMsgs_LostFocus(object sender, RoutedEventArgs e) { ListBox listBox = sender as ListBox; if (listBox != null) { listBox.SelectedItem = null; } }

Categories : C#

Removing item from a listbox that is binding to a database table
When in the form(ii) an user is deleting a phone number, just delete it from the db, so next time when the phone numbers are shown in the form(ii) the deleted phone number will not be there. If you do not want to make a post back on delete button click(which will erase the user added phone numbers in the list box as it has not been saved to the db till now), then make an AJAX call to the sever passing the values and delete the number.

Categories : Asp Net

How to save the information from additionally added fields in CreateUserWizard in separate database, which is different from the Membership database?
Inorde to store your custom data, you need to make use of, Membership profiles. You find more info over here http://msdn.microsoft.com/en-us/library/taab950e%28en-US,VS.80%29.aspx http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx http://odetocode.com/Articles/440.aspx

Categories : C#

How do I click a button that will remove an item from a ListBox and the List that holds the information for the ListBox in C#?
Your add method calls Add() on a base class. Do you have a remove on your base class? If so, use that. Otherwise change your ShoppingBasket class to be: The Orders list stores your OrderItems. Add and Remove from this list. public class ShoppingBasket { public List<OrderItem> Orders { get; set; } public ShoppingBasket() { Orders = new List<OrderItem>(); } public void Add(OrderItem orderItem) { Orders.Add(orderItem); } public void Remove(OrderItem orderItem) { Orders.Remove(orderItem); } } Usage: var basket = new ShoppingBasket(); basket.Add( new OrderItem { OrderItemId = 1, ... } ); // Remove an OrderItem basket.Remove( new OrderItem { OrderItemId = 1 } );

Categories : C#

Notify ListBox and ListBox Item for CRUD from Background Thread
To be straight to the point, creating new instance of the ObservableCollection every time your data changes then re-assigning it to the ItemSource, is not only disregarding core purpose of the ObservableCollection, it is also breaking/misusing the concept of Data Binding. //this is the line I am talking about: var Items = new ObservableCollection<Item>(notUploadedItems); Instead, create the ObserbaleCollection once -- make it a property: private readonly ObservableCollection<Item> _items = new ObservableCollection<Item>(); public ObservableCollection<Item> Items {get {return _items;} For the updates use collection's '.Add()' or 'Remove()' methods You're correct that you must be on the UI Main thread to do the updates: DoItOnUIThread(() =>Items.Add(newIt

Categories : SQL

Move and remove Listbox item to another listbox using jQuery in same places
Maybe you can simply set and remove the attribute "disabled" but it will leave a blank space in the options. Note that with this method you will need to clone the option the first time. The other solution whould be to add the content as usual but applying a sort() function before function byValue(a, b) { return a.value > b.value ? 1 : -1; }; function rearrangeList(list) { $(list).find("option").sort(byValue).appendTo(list); } $(function () { $("#button1").click(function () { $("#list1 > option:selected").each(function () { $(this).remove().appendTo("#list2"); rearrangeList("#list2"); }); }); $("#button2").click(function () { $("#list2 > option:selected").each(function () { $(this).remove().appendT

Categories : Javascript

How to split one large database table into multiple database tables
There is no special command to do this. Using a SELECT * INTO... is as succinct as it gets. If table size is your worry then you could use a table partition or view partition as an alternative to splitting the table.

Categories : Sql Server

efficient way to save custom form fields to database
If I understand this correctly, you're trying to use a one-to-one relationship where there should be a one-to-many. If you're going to have multiple Outcomes for one StateOption, may I suggest you use a many-to-many bridge table to link up which StateOption has which Outcome(s). Then in that bridge table you can also store the associated value as an additional column for the appropriate StateOption/Outcome pair.

Categories : Django

multiple input fields with same name. how to save them all into db
This is very easy.... You are posting all the information as an array. You obviously want 3 database entries to be inserted each time. (You could make life simpler by just having three different names) So on the php retrieval page you would do the following. <?php CONNECT TO DATABASE $itemname = $_POST['ball']; $subitem = $_POST['racket']; $quantity = $_POST['racket']; foreach($itemname as $itemname): foreach($subitem as $subitem): foreach($quantity as $quantity): SQL QUERY HERE INSERTING $itemname, $subitem, $quantity endforeach; endforeach; endforeach; Close SQL Connection ?> The above code will shoot off nine sql queries which is the ammount of combinations you could get. You could of course check to see is any value is empty and than skip inserting. Not quite sure wha

Categories : PHP

Disable input fields based on selection of mysql database item
You can disable fields like this using jquery $('selector').attr('disabled', 'disabled'); To enable again $('selector').removeAttr('disabled');

Categories : PHP

Link listBox with Database and show values in textBox if select index in listBox. C#
ideally i would change your listbox to datagridview and change your method like this void fill_listbox() { try { string constring = "datasource=sql2.freesqldatabase.com;port=3306;username=sql217040;password=xxxxx"; string Query = "select * from sql217040.fakedata ;"; using(MySqlConnection conDataBase = new MySqlConnection(constring)) { conDataBase.Open(); using (SqlDataAdapter a = new SqlDataAdapter(Query, conDataBase)) { DataTable t = new DataTable(); a.Fill(t); // Render data onto the screen dataGridView1.DataSource = t; // <-- datagridview1 is the gridview i have added } } } catch(Exception ex)

Categories : C#

move listbox item to another listbox?
You cant use foreach here because you change the listBox1.Items inside the loop, Use while loop and check the listBox1.Items.Count() >0 and inside the loop you can pic first item and move it to second one or remove. while (ListBox1.Items.Count>0) { var item = ListBox1.Items[0].ToString(); using (OracleCommand crtCommand = new OracleCommand("select count(*) from(( select * from all_ind_columns where index_name= '" + item + "' and table_owner='" + txtSrcUserID.Text.ToUpper() + "'))", conn1)) using (OracleCommand ctCommand = new OracleCommand("select count(*) from(( select * from all_ind_columns where index_name= '" + item + "' and table_owner='" + txtDesUserID.Text.ToUpper() + "'))", conn1)) { string result1 = crtCommand.ExecuteScalar().ToString();

Categories : C#

How to remove item from generic list that relates to item in listbox?
What you want to do is bind your ListBox to you List of employees. This post shows the binding and the comments shows the removing code as well. The idea is that when you remove an item from the DataSource, then you won't see it in the ListBox. Binding Listbox to List<object> The problem with the DeleteRecord() method is that the lstRecords object you just created isn't the ListBox that is on the form.

Categories : C#

How can I save each item in a "select multiple" field in its own MySQL record (using Rails)?
How can I save each waypoint in its own record in the Waypoint table? I'm able to get the first waypoint into the table, but the rest of the "select multiple" options are ignored. Unless you have a really good reason not to, use Rails' form helpers instead of rolling your own form fields. They will take care of this automatically, as well as handle edge cases you may not even know about. (Like the gotcha that sending a multiple select back with no selections will leave the record unchanged. That doesn't sound like it's an issue in your use case, but Rails still has your back if you use the form helpers.) In your case, you'd simply pass multiple: true in the html_options hash, like so: <%= f.select :waypointsselected, MasterLocation.waypoints_for_select, {}, { multiple

Categories : Mysql

Listbox contains does not find item, cannot remove an item
I c# all lists operation that are in some way required to compare objects use Equals or GetHashCode methods. In your case Equals and the default implementation wont check properties values it will only verify if the passed as argument object is in list so consider if you have the same instance in your list or just two different instances that happened to have the same properties. (the helpful VS option is make object id it will mark instance with a number) If this is the case then you should consider overriding Equals method or find the instance that you want to delete with linq for example and pas that object to Remove method.

Categories : C#

How can I find listbox item index with item value?
With listbox.Items.IndexOf("abber") That is: int curIndex = listbox.Items.IndexOf("abber"); if(curIndex >= 0) { MessageBox.Show(listbox.Items[curIndex].ToString()); }

Categories : C#

Filter by date range when the date is split into multiple fields
Do you have access to modify the DB schema? If so you could consider a 'generated column' for the date : https://www.ibm.com/developerworks/community/blogs/SQLTips4DB2LUW/entry/expression_generated_columns?lang=en

Categories : SQL

Update not pushing through to database when updating multiple fields
Look at your update query. Remove the , before the WHERE $updateQuery = ("UPDATE `users` SET email = '$_POST[email]', f_name = '$_POST[f_name]', l_name = '$_POST[l_name]', m_name = '$_POST[m_name]', phone = '$_POST[phone]', address = '$_POST[address]', city = '$_POST[city]', state = '$_POST[state]', zip = '$_POST[zip]', rights = '$_POST[rights]', comp_name = '$_POST[comp_name]', comp_tel = '$_POST[comp_tel]', comp_add = '$_POST[comp_add]', comp_city = '$_POST[comp_city]', comp_state = '$_POST[comp_state]' WHERE id = '$_POST[id]'");

Categories : PHP

How to save multiple xml files using SQL Server Database
Try with this script, maybe will be useful: CREATE PROCEDURE saveFile (@file varchar(1000), @txt VARCHAR(8000)) AS BEGIN DECLARE @sys_obj INT DECLARE @rst INT DECLARE @fID INT EXECUTE @rst = sp_OACreate 'Scripting.FileSystemObject', @sys_obj OUT EXECUTE sp_OAMethod @sys_obj, 'FileExists', @rst OUT, @file IF @rst=0 BEGIN EXECUTE sp_OAMethod @sys_obj, 'OpenTextFile', @fID OUT, @file, 8, 1 EXECUTE sp_OAMethod @fID, 'WriteLine', Null, @txt EXECUTE sp_OADestroy @fID EXECUTE sp_OADestroy @sys_obj END END And with this line, could be save to disk a String (for example a XML): EXEC saveFile @file = 'C: est.xml', @txt = '<xml><test>123</test></xml>'

Categories : Sql Server

How can I edit meta fields in multiple posts without database access?
This is impossible without FTP, Database Cpanel or Backend access. I'd spend your efforts on gaining access rather than a work around. If you have administration access install wp-dbmanager it will allow database table manipulation. Without database access you could only write a plugin to do this or export specific tables and edit them then re-upload them with the plugin above.

Categories : Wordpress

Display all datetime fields within a database with multiple table before a certain date
If your your field type is DateTime then you only have to use year function() If year(field.value) > 1900 Then 'codes here End If In VB you can do like this Dim dBirth as Date For x as Integer = 0 to MyTable.rows.Count-1 dBirth = MyTable.Rows(x).Item("birthdate") If dBirth > 1990 Then 'codes here End If Next

Categories : Sql Server

How to save multiple values in SQLite Database in Android?
first, you need to get the value of the selected item on your multi select spinner. Try this: ArrayList<String> content = new ArrayList<String>(); for (int j = 0; j < checkSelected.length; j++) { if(checkSelected[j]==true) { String values = BrandListAdapter.mListItems.get(j); content.add(values); } } Toast.makeText(getApplicationContext(), content.toString(), Toast.LENGTH_SHORT).show(); I toast the arraylist content just to check if it really contains the value I select. Then when you see the right value on your toast then you could save it on your database. Hope it helps! charot :D

Categories : Android

Should I be using hidden fields to preserve model fields between Edit and Save in ASP.Net MVC?
You can follows the steps as follows: Designing the model : public class ContactEditModel { public string PersonObjectName { get; set; } public string CompanyObjectName { get; set; } public string AddressObjectName { get; set; } .... } Create strongly type views : @model MyModels.ContactEditModel //Model Namespace @using (Html.BeginForm()) { @Html.TextBoxFor(m => m.PersonObjectName ) @Html.TextBoxFor(m => m.CompanyObjectName ) @Html.TextBoxFor(m => m.AddressObjectName ) @Html.ValidationMessageFor(m => m.Password) <input type="submit" value="Log In" /> } Working with Action public ActionResult Edit(ContactEditModel model) { return View(model); } [HttpPost] public ActionResult Edit(ContactEditModel model) { // Implementation

Categories : C#

I want to auto cursor when I input text in multiple textbox and save to database
to join all numbers as one using javascript: function UpdateNumber() { var num1 = document.getElementById(num1ClientID); var num2 = document.getElementById(num2ClientID); var num3 = document.getElementById(num3ClientID); var num4 = document.getElementById(num4ClientID); var fullnum = num1.value + num2.value + num3.value + num4.value; ex.value = fullnum; } ex is the label on your page where you display the whole number. You can call UpdateNumber() on the onkeyup event of each of your text boxes. Below is a code example for num1 (call UpdateNumber() for all textboxes). <input id="num1ClientID" type="text" onkeyup="UpdateNumber();" name="num1ClientID"> In your code behind, get the value of ex.

Categories : Asp Net

Save "Title" item to ListView and click on item to load data to new activity
Well, are you required to do this way(inflate a new view into the container)? or you just simply go with ListView, just add new Item, refresh the view and it's there. You can take a look at this example: The MainActivity: public class MainActivity extends Activity { private Button add; private MyAdapter adapter; private ArrayList<String> data; private ListView lv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); add = (Button) findViewById(R.id.button1); lv = (ListView) findViewById(R.id.listView1); data = new ArrayList<String>(); adapter = new MyAdapter(data); lv.setAdapter(adapter); add.setOnClick

Categories : Android

How to keep an item at the top of a ListBox
Sounds like a LongListSelector to me. There's a bit of work to be done but this link shows how to set it up.

Categories : C#

How to add an item to the top of a ListBox
You can use the ItemCollection.Insert Method For example myListbox.Items.Insert(0, myItem);

Categories : C#

Add Name property in every ListBox Item
Ok figured it out. I just had to capture the System.Windows.Input.MouseButtonEventArgs. And then very simple : private void StationsListLB_PreviewMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { var item = ItemsControl.ContainerFromElement(StationsListLB, e.OriginalSource as DependencyObject) as ListBoxItem; if (item != null) { var opa = e.OriginalSource as System.Windows.Controls.Image; MessageBox.Show(opa.Tag.ToString()); } }

Categories : C#

how to remove a item in listbox in vb
When you remove an item from the ListBox by pressing the Button2, the SelectedIndexChanged of the ListBox1 is being called. There, the selected item will be nothing, so to solve this, add the following lines inside the SelectedIndexChanged event before assigning the string variable. If ListBox1.SelectedItem Is Nothing Then Exit Sub End If

Categories : Vb.Net

Get id from selected item listbox
While filling the listbox, make a query to get the UserID column along with user name, user last name. Create a class that will represent each item of the list, such as public class UserInfo { public string DisplayName {get; set;} public int UserID {get; set;} } Make listUsers to be of List<UserInfo> type. While filling the data from the tables into the list, do the following while (myUserData.Read()) { listUsers.Add(new UserInfo() {DisplayName = myUserData["DisplayName"] , UserID = myUserData["UserID")}) } Post the list filling, use DataSource to bind the data, DisplayMember property to the DisplayName property, ValueMember property to UserID property. Look at this page for an example of how to use databinding for details.

Categories : C#

Read item from listbox in WPF
I prefer to address the problem by using the SelectedItem property of a ListBox or CurrentItem of a DataGrid and bind it to a property in my ViewModel. <ListBox ItemsSource="{Binding HarvestTimeSheet}" SelectedItem={Binding CurrentEntry}.../> <Button Content="Done Editing..." Command="{Binding DoneEditingCommand}"/> In my ViewModel I have private Harvest_TimeSheetEntry _currentHarvest_TimeSheetEntry; public Harvest_TimeSheetEntry CurrentHarvest_TimeSheetEntry { get { return _currentHarvest_TimeSheetEntry; } set { if (_currentHarvest_TimeSheetEntry == value) return; _currentHarvest_TimeSheetEntry = value; RaisePropertyChanged("CurrentHarvest_TimeSheetEntry"); } } This is set to the selecte

Categories : C#

select item listbox c#
The listbox is the sender object so you can access it like so. You just need to cast the sender as a listbox, then your selected item is a listbox item so you would cast it and then you can access the content values. Also when I created my selectionchanged event handler it accepts SelectionChangedEventArgs e not System.EventArgs e, SelectionChangedEventArgs is found in the System.Windows.Controls Namespace, which should already be imported into your class through using statement. var mySender = (ListBox)sender; swtich(((ListBoxItem)mySender.SelectedItem).Content.ToString()){ case "name 1": MessageBox.Show("X"); break; case "name 2": MessageBox.Show("X"); break; default: break; }

Categories : C#

How to read a record that is split into multiple lines and also how to handle broken records during input split
in your examples each record has the same number of lines. If that is the case you could use NLinesInputFormat, if it is impossible to know the number of lines it might be more difficult. (more info on NlinesInputFormat: http://hadoop.apache.org/docs/current/api/org/apache/hadoop/mapred/lib/NLineInputFormat.html )

Categories : Hadoop

save only edited listbox entries
Couple of ways of doing that. You can save each entry into a List<T> on every edit, or you can cache (pre-store) the ListBox items and after finishing editing you can compare the latest with the previous and extract out the edited items. IMO the first approach is better and easier to implement.

Categories : C#

how to save a listbox to existing file
Change the append option to false in the StreamWriter constructor Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click Using SW As New IO.StreamWriter("U: est" & Form1.ListBox1.SelectedItem & ".txt", False) For Each itm As String In Me.ListBox1.Items SW.WriteLine(itm) Next End Using End Sub

Categories : Vb.Net

How to set the font case of a listbox item in WPF?
You need a converter to achieve this behavior. public class CaseConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { TextInfo textInfo = culture.TextInfo; return textInfo.ToTitleCase(value.ToString()); } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException();; } } Add this as resource <Window.Resources> <local:CaseConverter x:Key="MyCaseConverter"></local:CaseConverter> </Window.Resources> and use it in XAML as <TextBlock Text="{Binding Name, Converter={StaticResource MyCaseConverter}}"/>

Categories : C#

Only highlight currently selected item in ListBox
You may do something like this. (This is just a skeleton. you will have to implement the class properly) public class MyImage { public string ImagePath { get; set; } public bool IsSelected { get; set; } } Set a collection of this class as the source of your listbox. When you select an item Mark IsSelected=true; Remember this property should be "false" for all unselected items. Now your borders visibility can be set based on IsSelected property.Hope this helps.

Categories : C#

listbox item forecolor change
First of all I suggest you to use background worker instead of directly writing down your code on UI thread. Please refer the code below: public partial class Form1 : Form { Brush myBrush = Brushes.Blue; public Form1() { InitializeComponent(); this.backgroundWorker1.DoWork += backgroundWorker1_DoWork; this.backgroundWorker1.RunWorkerCompleted += backgroundWorker1_RunWorkerCompleted; this.backgroundWorker1.RunWorkerAsync(this); } private void listBox1_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), listBox1.Font, myBrush, new RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height)); e.DrawFocusRectangle(); } priv

Categories : Vb.Net



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.