programming a Datalist

G

Guest

Hi All,
Environment: ASP.Net , framework 1.1, VS2003. Database: Sql server 2000

I have an MS DATALIST which has Item Templates, show the image and the price
right next to the "PRICE" text. the image name and the Price is being
populated from the datbase. All i do it get a datatable frm the database and
set it to the datasource of the grid it autoppulates it. The code in the HTML
section of the page for the grid which tells what fields are to be writen and
where to write them is :


<HeaderTemplate>
</HeaderTemplate>

<ItemTemplate>
<TABLE height=126 width=194 border=0>
<TR>
<TD><IMG height=136 src='<%# DataBinder.Eval(Container.DataItem,
"ProductImage") %>'></TD>
<TD class="plaintext">PRICE : '<%# DataBinder.Eval(Container.DataItem,
"price") %>'>
</TR>
</TABLE>
</ItemTemplate>

Now i want to add another field in their from the datatable which will haev
the sale price, and if their is a sale price for an item only then the Class
prperty of the PRICE Value should be "StiredNormalText" so that the price is
striked out and the the Sale price should appear benath it, once again if
their is no saleprice for an item then the CLASS of the Lable only for that
item should be "plaintext" and if their is then it should be
"StiredNormalText". their coudl be multuple records in the datatable. how can
i do this, can it be done? Please suggest.

Sameer
 
M

Michael Nemtsev

Hello Sameer,

If I understand you correctly, you need to dynamically create your cell's
controls on ItemDataBound event

S> Hi All, Environment: ASP.Net , framework 1.1, VS2003. Database: Sql
S> server 2000
S>
S> I have an MS DATALIST which has Item Templates, show the image and
S> the price right next to the "PRICE" text. the image name and the
S> Price is being populated from the datbase. All i do it get a
S> datatable frm the database and set it to the datasource of the grid
S> it autoppulates it. The code in the HTML section of the page for the
S> grid which tells what fields are to be writen and where to write them
S> is :
S>
S> <HeaderTemplate>
S> </HeaderTemplate>
S> <ItemTemplate>
S> <TABLE height=126 width=194 border=0>
S> <TR>
S> <TD><IMG height=136 src='<%# DataBinder.Eval(Container.DataItem,
S> "ProductImage") %>'></TD>
S> <TD class="plaintext">PRICE : '<%#
S> DataBinder.Eval(Container.DataItem,
S> "price") %>'>
S> </TR>
S> </TABLE>
S> </ItemTemplate>
S> Now i want to add another field in their from the datatable which
S> will haev the sale price, and if their is a sale price for an item
S> only then the Class prperty of the PRICE Value should be
S> "StiredNormalText" so that the price is striked out and the the Sale
S> price should appear benath it, once again if their is no saleprice
S> for an item then the CLASS of the Lable only for that item should be
S> "plaintext" and if their is then it should be "StiredNormalText".
S> their coudl be multuple records in the datatable. how can i do this,
S> can it be done? Please suggest.
S>
S> Sameer
S>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top