moving items netween listboxes


Hi ,  

I m using VS2008 with SQL server 2008 at the backend. I m creating a windows application in which I have 2 listboxes.the data is being retrieved from SQL server database in listbox1.i want to select few itms from this listbox and add them to second one through add button. PROBLEM: the values are being retireved from database but when i click add button after selecting a value from listbox1, System.Data.DataRowView is displayed in listbox2 automatically. listbox2 is not currently connected to any databse. here is the code



```
for (int i = 0; i < listBox1.Items.Count; i++) 
{ listBox2.Items.Add(listBox1.Items[i]); 
listBox1.Items.Remove(listBox1.SelectedItem); 
} 

```

i have also tried using this:



```
for (int i = 0; i < from.SelectedItems.Count; i++) 
{ to.Items.Add(from.SelectedItems[i].ToString()); }
 foreach (var item in new ArrayList(from.SelectedItems)) 
{ from.Items.Remove(item); } 

```

from and to are listbox1 and listbox2 respectively


any help will be appreciated
Did you bind the listBox1, using DataSource property from DataTable?  

If so, you have to 1st get the item and value from listBox item and add it some other place (in your case to listBox2):



```
for(int i = 0; i < listBox1.SelectedItems.Count; i++)
{
     DataRowView view = listBox1.SelectedItem as DataRowView;
     string item = view["ColumnNameOfItem"].ToString(); //can be some name
     int value = Convert.ToInt32(view["ColumnNameOfValue"]);  //can be some id (number)
     listBox2.Items.Add(item); // it you want to add item (you can add value as well);
}
```

ColumnNameOfItem (or OfValue) are the names of fields in your dataTable (and same are in dataBase as well). Insteads of names you can use indexes (0 and 1, but without quotation marks).



Hope it helps.  

bye
You could try using the in line view like this:


Select table1.col1, table1.col2, table1…., table2.col1, table2.col2, table2….  

 from  

(SELECT *  

FROM dbo.Shaft\_Scales  

WHERE dbo.Shaft\_Scales.ID = (SELECT max(ID) from dbo.Shaft\_Scales ID) as table1,  

(SELECT *  

FROM OtherTable  

WHERE dbo.OtherTable.ID = (SELECT max(ID) from dbo.OtherTable ID) as table2


—————- another approach from meandyou 


This works on [at least some] SQL processors


SELECT T1.* , T2.*  

FROM table1 T1, table2 T2  

WHERE …


Do we have to discuss why not to use “SELECT * ” in your SQL?<pre>


Try this


SELECT * FROM T1 as a, T2 as b WHERE a.ID = (SELECT max(ID) from T1)  

and b.ID = (SELECT max(ID) from T2);</pre> If I am not wrong, you are trying to read or loop through the rows from datatable. This error states that the datasource(DataTable) is not having any rows. To avoid this exception use this before you read or loop through datatable:  


```
if(dt.Rows.Count  > 0 ){
     //Do your stuff here.
}
```
  

  

  

--Amit Turns out If I tweked each method 



```
foreach (var dataColumn in readFields.Select(column => new DataColumn(columntypeof(string)) { AllowDBNull = true, DefaultValue = string.Empty }))
{
    csvData.Columns.Add(dataColumn);
}

```

and in the second Method I changed it to use an index rather than column name



```
for (var count = 0; count < table.Columns.Count; count++)
{
    sqlBulkCopy.ColumnMappings.Add(count, count);
}

``` hatayı buldum. tablomdan 2 alan çekip value değerine yazdırmaya çalıştığım için sanırım bu hata oluştu. value: value değerini value: value.kat\_ad olarak duzeltince sorun düzeldi hi andy,  

  

could you please explain in more details what exactly you need to achieve, because i am still not sure i understand you correctly?  

  

please note that when you are using the code below, you are overriding the text of the selected item - in your case this is the first item in the radcombombobox(with the empty text):  


`ddlfuturecode.selecteditem.text =` `"futurecode"`

  

if you want to select an item from the radcombobox by its text, you can use the following code instead:  


`ddlfuturecode.finditembytext(``"futurecode"``).selected =` `true`

  

so the changed vb code should look like the following:  


`dim` `ddlfuturecode` `as` `new` `radcombobox`
 
`with` `ddlfuturecode`
`.items.clear()`
`.items.add(``new` `radcomboboxitem(``""``, 0))`
`.items.add(``new` `radcomboboxitem(``"1"``, 1))`
`.items.add(``new` `radcomboboxitem(``"futurecode"``, 2))`
`.databind()`
`end` `with`
 
`ddlfuturecode.finditembytext(``"futurecode"``).selected =` `true`
 
`form1.controls.add(ddlfuturecode)`

  

  

regards,  

 aneliya petkova   

telerik

do you want to have your say when we set our development plans?
do you want to know when a feature you care about is added or when a bug fixed?
explore the [telerik feedback portal](http://www.telerik.com/support/feedback)
and vote to affect the priority of the items like this?

select a.itemcode

,isnull(c.citemname,b.itemname)

from produceitem as a

left outer join mastertable as b

on b.itemcode=a.itemcode

left outer join customeritemtable as c

on c.itemcode=a.itemcode

; I have figured out this issue and so for anyone else with the same issue.

In Designer for your XDP make sure you have a subform as the entry for the table row, and make this subform "Repeat Subform for Each Data Item" I found the subform could not be within another subform for this option to be visible.

So after this you can assign the row to the subform and the elements to the elements within the subform and hopefully it'll work.




[View solution in original post](/t5/adobe-experience-manager-forms/dynamic-rows-in-a-table-issue-also-relates-to-having-elements/m-p/204725#M6246) nothing missing - just different:

1.  transfers are still linked.  enter one side of the transfer and in the category drop-down, select transfer > [other account].  changing either of the two entries modifies the other.

2.  multiple registers at the same time.  you can have every register open at once in its own window.  only one register at a time shows in the main window.  just double-click the account in the left panel to open a floating register window.

3.  move transactions between accounts.  with both registers displayed, drag the transaction from one to the other.  if it is a downloaded transaction, you'll get a warning.  you cannot, however, move transactions between investment accounts. Hi Djhenry,
  

  
When you right-click a sheets tab, you can select all sheets. When you have done that, you can insert a row and enter all the information and all sheets wil contain that information.
  

  
Best regards,
  
Trowa First you need to clear the call in the database. `$mysqli->query`
  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

sent request before parameter binding, etc.


Replace as follows:



```
$stmt = $mysqli->prepare('SELECT reply\_id FROM replies WHERE reply\_topic = ? ORDER BY reply\_date ASC');
$stmt->bind_param('i',$param)
$stmt->execute();

        

        
        
        
 (adsbygoogle = window.adsbygoogle || []).push({});
 
        

    
```

 `$mysqli->prepare`
  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

returns a new object for which you want to bind values ​​and execute them. It avoids [SQL injection](https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=) !


None of this is discounted. `mysqli_`
  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

is exactly what you should be using.



  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

Since all you need is an array of results, you can use the following code to do this - no custom functions are required.



```
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
        $set[] = $row['reply\_id'];
}

        

        
        
        
 (adsbygoogle = window.adsbygoogle || []).push({});
 
        

    
```

For each row, `while`
  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

each field is stored in an array with the column name as the key. Thus, `$row['reply_id']`
  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

contains the value of a column `reply_id`
  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

in the database. Above, I have stored this value in a named array `$set`
  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

and when it iterates over the next row of the result, it also stores the next value for that array.


You can manipulate the result before or after saving it to a new array as you see fit.


Hope it helps.