By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,526 Members | 2,189 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,526 IT Pros & Developers. It's quick & easy.

DataGrid having ListBox and Hyperlink

P: n/a
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_SelectedIndexChan ged"/>
</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
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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).P arent.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.FindCont rol("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" <Ra**@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.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_SelectedIndexChan ged"/>
</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

Nov 19 '05 #2

P: n/a
Ollie,
Thank you so much.. This what exactly I wanted. May I ask you, why we are
doing 2 times Parent.Parent as in the statement

item = ((System.Web.UI.WebControls.DropDownList)sender).P arent.Parent;


"Ollie Riches" wrote:
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).P arent.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.FindCont rol("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" <Ra**@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.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_SelectedIndexChan ged"/>
</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


Nov 19 '05 #3

P: n/a
I believe the parent of the dropdown list is the cell and the parent of that
is the DataGridItem

--
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" <Ra**@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
Ollie,
Thank you so much.. This what exactly I wanted. May I ask you, why we are
doing 2 times Parent.Parent as in the statement

item = ((System.Web.UI.WebControls.DropDownList)sender).P arent.Parent;


"Ollie Riches" wrote:
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).P arent.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.FindCont rol("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" <Ra**@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.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_SelectedIndexChan ged"/>
</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


Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.