473,385 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Dynamic HTML in ASP.NET

Hello,

I can manage quite well in ASP but would like some
advice in the best way to achieve dynamic layout
in ASP.NET and still keep the page and code
separate.

Let's say I already have a data source which
contains a few records with a picture link and
a label. That's simple so far but now I would
like to display all the records in a table with
three items in a row, each item maybe in a
bordered cell with picture, label and a checkbox
for selection.

Now the question is what is the most efficient
way of laying this out. I have had a look at the
Repeater control but this will not do as I need
to add the checkboxes programmatically
depending on the item count.

So it seems that I could use a Placeholder control,
loop through my items and add all the table html
using Literal controls. Is this the best way of
doing this, or am I missing something completely?

Any advice will be much appreciated.
Jun 28 '06 #1
3 3244
Easiest is making use of the gridview control and then modify a cell to
become itemtemplate
The Bind() or Eval() can then be used in the SOURCE to obtain the
fielddata..

"Colin" <co***@digitalresearch.co.za> schreef in bericht
news:e7*********@ctb-nnrp2.saix.net...
Hello,

I can manage quite well in ASP but would like some
advice in the best way to achieve dynamic layout
in ASP.NET and still keep the page and code
separate.

Let's say I already have a data source which
contains a few records with a picture link and
a label. That's simple so far but now I would
like to display all the records in a table with
three items in a row, each item maybe in a
bordered cell with picture, label and a checkbox
for selection.

Now the question is what is the most efficient
way of laying this out. I have had a look at the
Repeater control but this will not do as I need
to add the checkboxes programmatically
depending on the item count.

So it seems that I could use a Placeholder control,
loop through my items and add all the table html
using Literal controls. Is this the best way of
doing this, or am I missing something completely?

Any advice will be much appreciated.

Jun 28 '06 #2
> Now the question is what is the most efficient
way of laying this out. I have had a look at the
Repeater control but this will not do as I need
to add the checkboxes programmatically
depending on the item count.
You can certainly do this with a Repeater, using Databinding expressions.

I'm still not sure what this has to do with keeping "page and code separate"
however. That is another issue altogether.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

Big thicks are made up of lots of little thins.
"Colin" <co***@digitalresearch.co.za> wrote in message
news:e7*********@ctb-nnrp2.saix.net... Hello,

I can manage quite well in ASP but would like some
advice in the best way to achieve dynamic layout
in ASP.NET and still keep the page and code
separate.

Let's say I already have a data source which
contains a few records with a picture link and
a label. That's simple so far but now I would
like to display all the records in a table with
three items in a row, each item maybe in a
bordered cell with picture, label and a checkbox
for selection.

Now the question is what is the most efficient
way of laying this out. I have had a look at the
Repeater control but this will not do as I need
to add the checkboxes programmatically
depending on the item count.

So it seems that I could use a Placeholder control,
loop through my items and add all the table html
using Literal controls. Is this the best way of
doing this, or am I missing something completely?

Any advice will be much appreciated.

Jun 28 '06 #3
I guess, Repeater control seems to be appropriate comparing to
PlaceHolder control. Because, you can very easily iterate thru the Data.

Lets see how it is easy. For example, I have the following aspx code

<asp:Repeater Id="repeater1" runat="server">
<ItemTemplate>
<asp:CheckBox Id="checkBox1" runat="server"></asp:CheckBox>
<asp:Image Id="image1" runat="server" />
</ItemTemplate>
</asp:Repeater>

Now, In the Page_Load Event I am binding the data to this control.

if (!IsPostBack)
{
//table is a DataTable object which the data needed to be populated
repeater1.DataSource = table;
repeater1.DataBind();
}

Once the data is binded, ASP.NET will call ItemDataBound event while
binding the data to the repeater control. I guess, you know how to
create ItemDataBound event for the repeater control.

Inside the ItemDataBound event,

void repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{

DataRow row = e.Item.DataItem as DataRow;

Image image1 = e.Item.FindControl("image1");
image1.ImageUrl = row["image"];
}
Now if you look at the code, you can easily understand how I am binding
the data to the Image control. This ItemDataBound will be called for
each and every row present in the table and binds the image column's
data to the ImageUrl property of image1 control.

Let me know in case you need further clarification.

-
Vadivel Kumar
http://vadivelk.net


Colin wrote:
Hello,

I can manage quite well in ASP but would like some
advice in the best way to achieve dynamic layout
in ASP.NET and still keep the page and code
separate.

Let's say I already have a data source which
contains a few records with a picture link and
a label. That's simple so far but now I would
like to display all the records in a table with
three items in a row, each item maybe in a
bordered cell with picture, label and a checkbox
for selection.

Now the question is what is the most efficient
way of laying this out. I have had a look at the
Repeater control but this will not do as I need
to add the checkboxes programmatically
depending on the item count.

So it seems that I could use a Placeholder control,
loop through my items and add all the table html
using Literal controls. Is this the best way of
doing this, or am I missing something completely?

Any advice will be much appreciated.

Jun 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Daniel Keller | last post by:
Hello! I'm trying to set up a page system using "dynamic" SSI. That means that I normally use the following on my website: <!--#include virtual="file.inc" --> Now I want to make this...
6
by: MikeY | last post by:
Hi Everyone, Does anyone know where I can get my hands on a sample with source code of a simple dynamic button control in C# Windows form. I am looking for a sample that uses a class library...
10
by: moondaddy | last post by:
I'm writing an ecommerce app in asp.net/vb.net and need to make the pages searchable and crawlable by spiders, particularly Google's. As far as I know, if my pages's contents are mostly populated...
1
by: Luis Ferrao | last post by:
Hi, To understand the problem, a small description of the situation should be provided: I have a Field Control that is made of a one row table with three columns. The table width is 100%, the...
7
by: Abraham Luna | last post by:
how do i stop the dynamic validators from breaking explorer if i use a dynamic validator and move to a different control it breaks explorer and i can type in the page when i'm not supposed to....
8
by: Sandy Pittendrigh | last post by:
I have a how-to-do-it manual like site, related to fishing. I want to add a new interactive question/comment feature to each instructional page on the site. I want (registered) users to be able...
10
by: maxvalery | last post by:
Because dynamic pages do not get indexed well in search engines, is there a decent API out there to parse through the site and write pages as plain html automatically? I noticed some WordPress and...
5
by: pittendrigh | last post by:
There must be millions of dynamically generated html pages out there now, built by on-the-fly php code (and jsp, perl cgi, asp, etc). Programatic page generation is transparently useful. But...
7
by: Jo | last post by:
Hi, How can i differentiate between static and dynamic allocated objects? For example: void SomeFunction1() { CObject *objectp = new CObject; CObject object;
9
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.