Re: DataGrid having ListBox and Hyperlink

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Ollie Riches (ollie.riches_at_phoneanalser.net)
Date: 02/16/05


Date: Wed, 16 Feb 2005 16:26:22 -0000

so you when a user selects a entry in the drop down list you want to change
the hyperlink on the post back event?

If so what you want to do is add a handler for the drop down list and do
something like this get the current datagrid item index.

private void ddlXXX_SelectedIndexChanged(object sender, System.EventArgs e)
{
    System.Web.UI.WebControls.DataGridItem item = null;
    item = ((System.Web.UI.WebControls.DropDownList)sender).Parent.Parent;

    int currentIndex = item.ItemIndex;
    string newUrl = "<MAKE URL>";

    System.Web.UI.WebControls.HyperLink link = null;
    System.Web.UI.WebControls.HyperLink =
(System.Web.UI.WebControls.HyperLink)item.FindControl("PocketDetails'");

    link.NavigateUrl = newUrl;
}

--
HTH
Ollie Riches
http://www.phoneanalyser.net
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer.  I'm just a programmer
helping programmers.
"Raja" <Raja@discussions.microsoft.com> wrote in message
news:FD17079E-EA5C-449C-842F-290441E74255@microsoft.com...
> I have a datagrid, it has dropdown box as a column and i have one more
column
> that has hyperlink. The NavigateURL for the hyperlink is to open a new
window
> with a query stirng parameter as the selected value of the drop down...
>
> here is how it looks like
>
> <asp:datagrid....>
> ...
> <asp:TemplateColumn>
>   <ItemTemplate>
>     <asp:ListBox
>               ID="ItemList" Runat="server"
>               AutoPostBack="True"
> OnSelectedIndexChanged="DropDown_SelectedIndexChanged"/>
>   </ItemTemplate>
> </asp:TemplateColumn>
> <asp:TemplateColumn>
>   <ItemTemplate>
>       <asp:hyperlink runat='server' id='PocketDetails'/asp:hyperlink>
>   </ItemTemplate>
> </asp:TemplateColumn>
>
> ...
> </asp:datagrid>
>
> The url for the hyperlink contorl ("PocketDetails") has to be created
> dynamically and with the querysting parameter as the selected value of
> dropdown box ("ItemList").
>
> How do I achieve this?
>
> Thanks for your help


Relevant Pages

  • Re: working with 2 or vbas on the same sheet
    ... hyperlink when i click on say google on the dropdown rather then clicking the ... Private Sub Worksheet_Change ... If Intersect, Target) Is Nothing Then ...
    (microsoft.public.excel.programming)
  • Re: Drop Down Hyoerlink
    ... The dropdown can't hold a hyperlink, but there may be some workarounds. ... > I have a Excel sheet that is seven to eight pages long... ... > sheets format so that when i select a certain heading in the drop down menu ...
    (microsoft.public.excel.misc)
  • DataGrid having ListBox and Hyperlink
    ... it has dropdown box as a column and i have one more column ... The NavigateURL for the hyperlink is to open a new window ... with a query stirng parameter as the selected value of the drop down... ... <ItemTemplate> ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Getting HyperLinked Cell to Appear at the Top of the Screen
    ... > right click on the sheet tab (with the hyperlink) and select View code. ... > In the left dropdown, ... > It has an argument target which is a hyperlink object. ... > Private Sub FollowHyperlink(Target as Hyperlink) ...
    (microsoft.public.excel.programming)