Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add new row to Datagrid

Status
Not open for further replies.

vedicman

Programmer
Sep 5, 2003
128
0
0
US
Is there a way to add a new row in the first row under the header of a datagrid, instead of adding the new row at the bottom in the footer? If so, please provide a code sample of how to do it.

Thanks....Franco
 
do you mean in the itembound? the only way would be to use textboxes instead of labels putting your grid in an "edit mode" all the time.

Why don't you want to use the footer?

 
dvannoy

Thanks for responding. Personally I have no problem with having the add row in the footer. My boss is the one who would like it at the top because the data grid is more than 40 columns wide and each week a new row is added and now that we're in to week 22 or thereabouts you can no longer see the column names in the header. Any ideas for a simple solution?

Thanks....Franco
 
You could also use an anchor tag to position the page at the relevant point.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
dvannoy....

Is there a way to have the scroll bars appear on the left side of the datgrid?


ca8msm....

Would you provide a code sample using an achor tag to make the page appear at 'the relevant point'? My problem is not being able to see the header row when adding a new row at the bottom of the datagrid.

Thnk you both....Franco
 
Sorry, I mis-read the post - the link dvannoy posted will do what you want.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Oh, and you can move your scrollbars to the left with CSS but it's not supported in all browsers:


Not particularly keep on it myself though as it's not what most users would have expected.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
What about having two table rows in the header and making the bottom one textboxes and a button. You would probably need to use a datalist for this though (but datalists rock).
 
You can do it another way - if you add an empty row to your datasource at position 0, you can hide if you are not in "insert" mode or show it if you are. e.g.



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
ca8msm,

will that "insert" row always stay on top even after the first record gets inserted?

if so, I may change a few things around with one of my apps.

 
I'm not sure if that example does or not but it should be easy enough to implement if not.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
you know, now that I am thinking about this more...it really doesn't matter if your inserting records at the top of the grid. when the grid rebinds itself, that newly added record will go straight to the bottom of the grid. to avoid that, you would have to sort by the record ID DESC; so the last record ends up at the top.

 
hi guys,

the scrollable datagrid is a great idea.

i thought i could add my suggestions also to this particular point:

>>Is there a way to add a new row in the first row under the header of a datagrid

there is a javascipt based solution for this too, the datagrid that is outputted is a table right? and using JS (DOM) one can control the tabe structure itself, therefore adding a first row that way would be simple (the row must always be inserted at position 1, i.e. below the header row).

i can give u a sample, but that is only if the poster is interesed in a JS solution.

the drawbacks:
1. If JS is disabled then it wont work.
2. State cannot be preserved for rows created by JS(but it can be overcome easily).

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top