how to set table row values descending in order
i am creating dynamic tableview which includes 3 columns and rows as per my input value entered. the value will display on the first column as per the input entered.

my table row will be updated like

0
20
40
60
80
100
etc...

my code is

 stk.addview(tbrow0);
 for (int i = 0; i < input1 / input2 + 1; i++) {
 tablerow tbrow = new tablerow(this);
 textview t1v = new textview(this);
 t1v.settext("" + i * input2);
 t1v.settextcolor(color.black);
 t1v.setgravity(gravity.center);
 t1v.settextsize(12); 
 t1v.setbackgroundresource(r.drawable.border);
 tbrow.addview(t1v);

i want to display the values in descending order (high to low) in the first column.

100
80
60
40
20
0

i don't know how to modify my code. pls guide me
> [[cite senthil kumar.p]]
>
> yes this is android studio project.
> 
> both input 1 and input 2 are integers.
> example:
> input1 = 1000
> input2 = 20
> 
> it will create total 50 rows and the order is 
> 0
> 20
> 40
> 60
> etc.....
> 
> 

do you need the codes as below? 
......
for (int i = input1 / input2; i >=0; i--) {
 ......
 t1v.settext("" + i * input2);
 ......
i would do it like this:

https://www.advanced-excel.com/columns-to-rows.html 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 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) Should be able to do something like this:


UPDATE table\_name  

SET new\_column = (calculated value)  

WHERE new\_column is NULL 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);
}

``` 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> hi [@maddy](/u/maddy),

i believe the issue here is that you've specified order here but not the filed to order it by, to quote the docs:

you use two parameters for this argument: field to specify the prismic field id and order to specify if you want it sorted ascending (asc) or descending (desc). you can use… Thanks for your reply, I feared it would not be trivail, as I coudnt find any scripts. Idealy the text from the databse is place in a table witht the last column beeing the barcodes path, the images are to replace the text path and be place inside the cell, fitting within the cells width and/or height. [@najoua.abbaci](/u/najoua.abbaci)

mabye the flow can be adopted to following:

assign:

leftside: drresult (datatype: datarow)

right side:

dt\_datepv.asenumerable.orderby(function ( r ) datetime.parseexact(r(0).tostring.trim, “dd.mm.yyyy”, system.globalization.cultureinfo.currentuiculture.datetimeformat)).last()

so… %%
var1= [1 1 2 4 5 7 7 7 8 10 11 13 14 14 17 17 17 17 18 20];
var2= [0.5 0.3 0.1 0.6 0.2 0.4 0.8 0.9 0.3 0.2 0.1 0.4 0.8 0.7 0.5 0.9 0.2 0.8 0.3 0.7];

x=min(var1):1:max(var1);
newele1=setdiff(x,var1);
newele2=nan(size(newele1));

newvar1=[var1,newele1];
newvar2=[var2,newele2];

[newvar1,index]=sort(newvar1);
newvar2=newvar2(index)