HELP!DataGrid HyperLink Highlighting??

S

steroche

I have a datagrid that passes values to one page to another - well it
actually loads up the same page again with the param passed in so i can
poplulate another datagrid from that parameter if you know what i mean.



My question is this: How can i make the datagrids' row highlight(like
the way when you click select btn) and have this behaviour persist into
the next page load?As in so i can see the 2 datagrids but i can tell
what value i selected in the 1st grid as its now highlighted..
Any suggestions greatly appreciated as this has been puzzling me for
days!

Thanks,
Steve
 
E

Eliyahu Goldin

Steve,

If you want to immitate select btn click, add a hidden column to the
datagrid:

<asp:ButtonColumn ButtonType="LinkButton" CommandName="Select"
Visible="False"></asp:ButtonColumn>

and handle the ItemDataBound event like this:

protected void dgUserGroup_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
ListItemType itemType = e.Item.ItemType;
if ((itemType == ListItemType.Pager) ||
(itemType == ListItemType.Header) ||
(itemType == ListItemType.Footer))
{
return;
}
LinkButton button = (LinkButton) e.Item.Cells[0].Controls[0];
e.Item.Attributes["onclick"] = this.GetPostBackClientHyperlink
(button, "");
}

The example assumes the the hidden column is placed in the very first
position in the grid.


Eliyahu
 
S

steroche

Thanks Eliyahu ,
This works great for selecting anywhere iside my datagrid but is there
any way that i can get it to work for selecting a hyperlink column
aswell? I am selecting a column, passing the paramaters to the same
page again so that i can populate the datagrid form that value and it
would be niceif i could make the row highlight when i do this.
Thanks,
Steve
 

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,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top