best way of showing single record
-
hi what is best practice for showing single record from DataSource controls (SqlDataSource, AccessDataSource, ...) this is quite common situation; lets say i need to show simple data from database based on id that is passed via querystring using repeater for only one record feels wrong?
<%#Eval("Name") %> <%#Eval("HTML") %>
<%=DetailHTML() %>
<SelectParameters> </SelectParameters>
-
hi what is best practice for showing single record from DataSource controls (SqlDataSource, AccessDataSource, ...) this is quite common situation; lets say i need to show simple data from database based on id that is passed via querystring using repeater for only one record feels wrong?
<%#Eval("Name") %> <%#Eval("HTML") %>
<%=DetailHTML() %>
<SelectParameters> </SelectParameters>
I would be inclined to create a suitable control on the form and then populate it from code behind. That way you can render the control with any styles, etc, ready to accept the value. Perhaps like:
In the
OnLoad
event (or wherever you deem appropriate):if (!IsPostBack)
{
result = GetStringValueFromDatabase(Parameter);
Label1.Text = result;
}or similar.,
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
hi what is best practice for showing single record from DataSource controls (SqlDataSource, AccessDataSource, ...) this is quite common situation; lets say i need to show simple data from database based on id that is passed via querystring using repeater for only one record feels wrong?
<%#Eval("Name") %> <%#Eval("HTML") %>
<%=DetailHTML() %>
<SelectParameters> </SelectParameters>
-
It really is up to you. You can use a grid view, a datalist, textboxes, labels, etc. It all depends.
There are only 10 types of people in the world, those who understand binary and those who don't.
ye, i know... i need to develop master page for portal that has content like this: //////////////////////////// //div // //Check our latest product! //////////////////////////// //////////////////////////// //div // //Pool: What do you think? //1. //2. //3. //////////////////////////// //////////////////////////// //div // //TOP 1 video //////////////////////////// //////////////////////////// //div // //Latest client activites //////////////////////////// ...many more so i have plenty of "single record" DataSources (queries like "select something from myTable where id=1") the way i did this is: //////////////////////////// //div // // //////////////////////////// //////////////////////////// //div // // //////////////////////////// //////////////////////////// //div // // //////////////////////////// //////////////////////////// //div // // //////////////////////////// but using x repeaters for x "single record" DataSoruces feels wrong. so i am just wondering is this approach ok?
-
ye, i know... i need to develop master page for portal that has content like this: //////////////////////////// //div // //Check our latest product! //////////////////////////// //////////////////////////// //div // //Pool: What do you think? //1. //2. //3. //////////////////////////// //////////////////////////// //div // //TOP 1 video //////////////////////////// //////////////////////////// //div // //Latest client activites //////////////////////////// ...many more so i have plenty of "single record" DataSources (queries like "select something from myTable where id=1") the way i did this is: //////////////////////////// //div // // //////////////////////////// //////////////////////////// //div // // //////////////////////////// //////////////////////////// //div // // //////////////////////////// //////////////////////////// //div // // //////////////////////////// but using x repeaters for x "single record" DataSoruces feels wrong. so i am just wondering is this approach ok?
It isn't wrong because it allows for future flexibility but you may want to create a user control for each of those items and just use labels and textboxes or whatever you want in the control. Then just add as many of the usercontrols onto your page. That may make management of it easier.
There are only 10 types of people in the world, those who understand binary and those who don't.