c# - asp.net how to remove all the rows from a table except the first one -


in past using this

datebookingtable.rows.clear(); 

to remove rows.

now want remove rows except first one.

why want that?

because when remove rows, th removed, don't want that. want remove data. not th

this don't want remove

<tr><th>id</th><th>plantime</th></tr> 

what have tried

i make loop:

for (int = 0; < datebookingtable.rows.count; i++) {                  if (i >0){                 //here should                 }             } 

but didn't know how remove row in looop

in loop can use

datebookingtable.rows.removeat(i); 

you can modify loop start 1 instead of 0 , avoiding checking against 0 in each iteration.

for (int = 1; < datebookingtable.rows.count; i++) {     datebookingtable.rows.removeat(i); } 

if want remove rows client side using jquery can do:

 $('#yourtableid').find("tr:gt(0)").remove(); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -