Last post Mar 06, 2018 07:08 AM by mmy1981
Mar 05, 2018 10:51 AM|mmy1981|LINK
Hi, I'm quite new to web programming (have some experience with windows forms in vb.net) and I would like some direction/best-practice to achieve the following:
I have a accdb database /source with info like:
I want to display this info on a webpage, using a gridview (or <table>) in addition with bootstrap for the layout.
However, I don't want the looks of a static table with each info part in a separate column like this:
Instead, I would like the info showed as a label with a specific hyperlink (or maybe button) at the end. Something like:
- companyA is opened (A@company.com) - open/close company
- companyB is closed (B@company.com) - open/close company
- companyC is opened (C@company.com) - ....
--> where open/close... will be a button or hyperlink to change the status.
Can this be done populating a gridview with a datasource or datareader?
Or should I read the data and edit the info in the RowDataBound sub? So, every time a row is printed, I check the content and format the label accordingly?
Or do I have to display it as a <ul> with items instead of using a GridView or table?
Or maybe create a class "company" with one label into it. Cycle through each found item, fill the class (label = combination of the columns like I want it to display) and bind this class to the Gridview?
Mar 05, 2018 12:07 PM|uid895650|LINK
The best place to start is to look at the Microsoft web site for tutorials e.g. https://docs.microsoft.com/en-us/aspnet/web-pages/overview/data/5-working-with-data
Or here on asp.net - the learn section has tons of stuff: https://www.asp.net/mvc or https://www.asp.net/mvc/overview/models-data
Sorry, the answer might be broad and I think you might need to grips with basics - which these sites are awesome at.
A simple example to get you started: https://www.aspsnippets.com/Articles/Display-data-in-GridView-in-ASPNet-from-SQL-Server.aspx
Hope this helps.
Mar 06, 2018 12:36 AM|oned_gk|LINK
You can use templatefield in gridview, repeater, listview etc
Place some text and some controls like label, hyperlink or button.
You can bind label text, button text, hyperlink url to the fieldname from the datasource.
Or you can generate yourown html code i.e : <li><%# eval("fieldname") %></li>
Mar 06, 2018 07:04 AM|Cathy Zou|LINK
You could use DataList or Repeater
Various Data Bound Controls Used in ASP.Net
Mar 06, 2018 07:08 AM|mmy1981|LINK
thanks for the replies. I know I should view some tutorials to get the new basics.
Though, I'm familiar with windows forms - and did some basis project with web applicaties somethimes I struggle to find the right objects (or don't know which layouts are possible).
But indeed, I started with the gridview and use some databound fields to get the info I need and templatefields to show it in a specific way.
Afterwards I'll hide the databound fields. I don't think this is the best ore most performant way, but at this moment it does the trick...
I was also playing with the DataList, also seems ok. I'll check the tutorial for sure!