Create GridView Column

  • Thread starter Miguel Dias Moura
  • Start date
M

Miguel Dias Moura

Hello,

I have a dataset with 2 fields, [Text](String) and [Approved](Boolean).

I want to add, FROM the ASPX.VB Code, 2 columns:

1. Column which will display the Text field.
I need this column to recognize HTML tags.
The [Text] field might be something like
"<h1>Heading</h1><p>Paragraph</p>

2. Column which will display an image:
It will display "Verified.gif" if Approved is True.
It will display "NotVerified.gif" if Approved is False.

I have been trying to do this but until now I wasn't able to get what I
need.
Please, don't forget I am trying to create the columns from the ASPX.VB
code.

Could someone, please, help me with this?

Thank You,
Miguel

P.S: I am working on Asp.Net 2.0.
My GridView is allready binded to the dataset.
 
G

Guest

For both instances use the Tamplate Column. Thith the Template Column you
can do anything.

For #1 you could add in a literal control so that you could add any kind of
html to it.

For #2 you could Use the image control and reference the bound data like
this:

Create a function that will return either a verified.gif image path or a
notverified.gif image path like so:

In your VB code:

Function getImagePath(byval boolApproved as boolean) as string
Dim strPath as string

If boolApproved = True then
strPath = "verified.gif"
End If

If boolApproved = False then
strPath = "notverified.gif"
End If

Return strPath
End function

Now in your template column inside the item template tag and inside the
asp:image tag put this as your image path:

In your HTML:

imagePath='<# getImagePath(Eval("Approved")) #>'

Hope this makes sense.

Anyone else tap in if you got another way of doing this.

If this code is sloppy forgive me as I am just doing this from the top of my
head.

Thanks,

J
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top