-
views
using vb.net here
instead of using a datagrid to display data from SQL, is there another way where i can customly make and put the data retrieved from SQL (can be x amount of records) on the screen?
datagrid really to me isnt easy to design with, like you may want an odd row to be a different color or maybe have a "header" and or a footer in each record retrieved, this would then contain the data and time or whatever....
any ideas?
-
Re: views
Have you used the Repeater control? It binds in the exact same way, but, you have an enormous amount of control on how the data is actually presented!
-
Re: views
never heard of that! thanks :D
-
Re: views
Ahhh I think you'll be pleasantly surprised by the Repeater control. Drag one onto your web form, and then go into HTML Source view.
The main thing you'll want to do is create the <itemTemplate></itemTemplate> template (just fill in between those two with HTML). You can also specify alternating item templates, footer templates, header templates etc.
And to display the actual data, in the HTML code you'd do something like this:
Code:
<itemTemplate>
Something: <%# Container.DataItem(0) %> <br>
Something Else: <%# Container.DataItem(3) %> <br>
</itemTemplate>
You'd normally have a HTML table in there, but I'm not going to write out a html table by hand ;)
The way I normally do this is to design a nice looking table in Dreamweaver with some temp or test data, and then convert it into a more template form for use above.
Very cool control ;)
-
Re: views
Or
Code:
<itemTemplate>
Something: <%# Databinder.Eval(Container.DataItem, "FieldName1") %> <br>
Something Else: <%# Databinder.Eval(Container.DataItem, "FieldName2") %> <br>
</itemTemplate>
-
Re: views
Personally I find a datagrid slightly better.
You can do all that the repeater does, but the grid gives you more things.
You can create column style classes that enable you to create templated for cells in ya grid.
Woka
-
Re: views
Memnoch;
True, but passing the field name by String value is a lot slower than by field index. Having said that, passing the specific index can be dangerous if the table structure changes.... :shrug:
Woka;
Never used them myself, just normally stick with the 'ol Repeater :)
-
Re: views
-
Re: views
-
Re: views
lol sorry my bad - misunderstood it.... :)