Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

how to continue row number increasingly while filling data to datatable.?

$
0
0

 hi,

i have the few records in database like follows:

Record 1.   

Rowno     name

1             christ

2              william

3              Albert.

Record 2.

Rowno   Name

1           Martin

2           Allen

3           Moorthy.

in code behind c#. i am binding first record into table using select query like,

sqlcommand cmd=new sqlcommand("select * from record1",con);

datatadapater adap=new dataadapter(cmd);

datatable dt=new datatable();

datatable mergedt = new datatable();

adap.fill(dt);

And,

similarly i am binding second record and filling to another datatable.

sqlcommand cmd=new sqlcommand("select * from record1",con);

datatadapater adap=new dataadapter(cmd);

datatable secoddt = new datatable();

datatable mergedt = new datatable();

adap.fill(secoddt );

Till now everyhing works fine.

Here, i need to merge the both table 1 and table 2. so, i merged table 2 value into table 1 like follows.

dt.merge(secoddt);

now i got results of two table value in one table.

but row number comes like follows:

Rowno name

1          christ

2          william

3          Albert

1          Martin

2          Allen

3          Moorthy  // can you see the row number did not come in accending order.  it comes 1,2,3 and again it repeats 1,2,3...i need to display row number like 1,2,3,4,5,6:

The result should display

Row no    Name

1             christ

2             William

3             Albert

4             Martin

5             Allen

6             Moorthy.

Please help.


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>