Re: I am a beginner.Pls help me

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



A HyperlinkColumn will just render as a HTML anchor (<a>) and thus will just be a link off to some other page. The only code that will handle the click is the other page itself. If you want a postback when they click the link, I'd suggest using a ButtonColumn instead (you can make it look like a hyperlink). Then you need to handle the Grid's ItemCommand event and in there you get to handle the click. So, here's the column:

<asp:ButtonColumn Text="Click Me" ButtonType="LinkButton" CommandName="Foo"></asp:ButtonColumn>

Note I gave a CommandName -- this is how in your ItemComment event you'll know which column it was. Then your ItemCommand would look like this:

protected void _grid_ItemCommand(object source, DataGridCommandEventArgs e)
{
   if (e.CommandName == "Foo")
   {
       DataGridItem row = e.Item;
       // now use row to do whatever you want
   }
}

Notice the check for "Foo" -- this means it was your column. You can then fetch the row that was clicked by accessing DataGridCommandEventArgs.Item.

-Brock
DevelopMentor
http://staff.develop.com/ballen



I have a datagrid with a hyperlink column. Now i want to program for
the click on the hyperlink. where do i put my code?




.



Relevant Pages

  • Re: Pb with skinID in templated columns having DataBinder.Eval
    ... Walter, it looks like a MS bug. ... In fact when we set a SkinID in an hyperlink used in a Datalist, ... So we transformed the imageurl set from the skin, removed the ~ and Render ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: wrapping text in a datagrid cell
    ... I neglected to mention -- I am outputting this url as a ... hyperlink. ... When I render the text in the cell on ... Even doing that causes the cell to be the width of the URL. ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • Can I render hyperlinks in Vegas 5 that maintain interactivity?
    ... I am attaching this .swf file to the end of an .AVI file. ... I render it as a .wmv in Vegas 5, I lose the hyperlink. ...
    (rec.video.desktop)
  • Disabling HREF
    ... when a user clicks on the HTML Anchor i don't want anything to happen ... i have put a put_onclick on the document itself and cancel the bubble ... but the hyperlink still works! ...
    (microsoft.public.vc.atl)