Re: I am a beginner.Pls help me
- From: Brock Allen <ballen@xxxxxxxxxxxxxxxxx>
- Date: Tue, 19 Apr 2005 02:02:05 -0700
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?
.
- References:
- I am a beginner.Pls help me
- From: Meena via DotNetMonster.com
- I am a beginner.Pls help me
- Prev by Date: Re: Designer locking mdb file... (file and dir GRANTS FULL CONTROL FOR "EVERYONE")
- Next by Date: filtering from multiple dropdownlists
- Previous by thread: I am a beginner.Pls help me
- Next by thread: filtering from multiple dropdownlists
- Index(es):
Relevant Pages
|