Apply css to asp:HyperLinkColumn

M

Maziar Aflatoun

Hi everyone,

Does anyone know how I can apply the css 'linksmall' to my hyperlink in my
datagrid?

I have the following and it doesn't work
<asp:HyperLinkColumn Text="Edit" DataNavigateUrlField="PID"
ItemStyle-CssClass="linksmall"
DataNavigateUrlFormatString="ManageItem.aspx?PID={0}">

I need to add it to my href='' tag.

Thank you
Maziar A.
 
E

Eliyahu Goldin

In ItemDataBound event set
e.Item.Cells[xx].Attributes["class"]="linksmall";
where xx is the index of the column with the hyperlink

Eliyahu
 
M

Maziar Aflatoun

That doesn't work because it assigns the css to the cell and not the href.
What I need is

<td class="linksmall"><a href="ManageItem.aspx?PID=24"
class="linksmall">Edit</a></td>

instead of
<td class="linksmall"><a href="ManageItem.aspx?PID=24">Edit</a></td>

Any idea?

Thank you
Maziar A.


Eliyahu Goldin said:
In ItemDataBound event set
e.Item.Cells[xx].Attributes["class"]="linksmall";
where xx is the index of the column with the hyperlink

Eliyahu

Maziar Aflatoun said:
Hi everyone,

Does anyone know how I can apply the css 'linksmall' to my hyperlink in
my
datagrid?

I have the following and it doesn't work
<asp:HyperLinkColumn Text="Edit" DataNavigateUrlField="PID"
ItemStyle-CssClass="linksmall"
DataNavigateUrlFormatString="ManageItem.aspx?PID={0}">

I need to add it to my href='' tag.

Thank you
Maziar A.
 
E

Eliyahu Goldin

Maziar,

First of all, if you've assigned a class to <td>, it will format the cell
content in the way your want. I don't think there is any reason for setting
the same class for the <a>.

Secondly, I had another look at your problem. The solution is
<asp:HyperLinkColumn Text="Edit" DataNavigateUrlField="PID"
DataNavigateUrlFormatString="ManageItem.aspx?PID={0}">
<ItemStyle CssClass="linksmall"></ItemStyle>
</asp:HyperLinkColumn>

Eliyahu

Maziar Aflatoun said:
That doesn't work because it assigns the css to the cell and not the href.
What I need is

<td class="linksmall"><a href="ManageItem.aspx?PID=24"
class="linksmall">Edit</a></td>

instead of
<td class="linksmall"><a href="ManageItem.aspx?PID=24">Edit</a></td>

Any idea?

Thank you
Maziar A.


Eliyahu Goldin said:
In ItemDataBound event set
e.Item.Cells[xx].Attributes["class"]="linksmall";
where xx is the index of the column with the hyperlink

Eliyahu

Maziar Aflatoun said:
Hi everyone,

Does anyone know how I can apply the css 'linksmall' to my hyperlink in
my
datagrid?

I have the following and it doesn't work
<asp:HyperLinkColumn Text="Edit" DataNavigateUrlField="PID"
ItemStyle-CssClass="linksmall"
DataNavigateUrlFormatString="ManageItem.aspx?PID={0}">

I need to add it to my href='' tag.

Thank you
Maziar A.
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top