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

Listbox inside a DataGrid

P: n/a
I have a simple question, I have a datagrid and inside the grid, i have List
box. I am able to render the page with the datagrid and the lisbox values.
Now, my question is how to trap the server side SelectedIndexChanged event of
the listbox.

Any help in VB.NET would be greatly appreciated.

Thanks

Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Raja:

I assume inside the grid definition you have something like:

<asp:TemplateColumn>
<ItemTemplate>
<asp:ListBox
ID="ItemList" Runat="server"
AutoPostBack="True"

OnSelectedIndexChanged="DropDown_SelectedIndexChan ged"/>
</ItemTemplate>
</asp:TemplateColumn>

The key is setting the AutoPostBack property to true and declaring an
event handler inside the tag. Then add an event handler in the code
behind - the sender parameter will be a reference to the ListBox.

Make sense?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 15 Feb 2005 11:49:01 -0800, "Raja"
<Ra**@discussions.microsoft.com> wrote:
I have a simple question, I have a datagrid and inside the grid, i have List
box. I am able to render the page with the datagrid and the lisbox values.
Now, my question is how to trap the server side SelectedIndexChanged event of
the listbox.

Any help in VB.NET would be greatly appreciated.

Thanks


Nov 19 '05 #2

P: n/a
Scott,
Thanks for your quick reply. This is very helpful. I have a further
question, hope you will be able to help me.

As I mentioned I have a grid and the gird 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: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>

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").

Please help me.

Thanks
Raja
"Scott Allen" wrote:
Raja:

I assume inside the grid definition you have something like:

<asp:TemplateColumn>
<ItemTemplate>
<asp:ListBox
ID="ItemList" Runat="server"
AutoPostBack="True"

OnSelectedIndexChanged="DropDown_SelectedIndexChan ged"/>
</ItemTemplate>
</asp:TemplateColumn>

The key is setting the AutoPostBack property to true and declaring an
event handler inside the tag. Then add an event handler in the code
behind - the sender parameter will be a reference to the ListBox.

Make sense?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 15 Feb 2005 11:49:01 -0800, "Raja"
<Ra**@discussions.microsoft.com> wrote:
I have a simple question, I have a datagrid and inside the grid, i have List
box. I am able to render the page with the datagrid and the lisbox values.
Now, my question is how to trap the server side SelectedIndexChanged event of
the listbox.

Any help in VB.NET would be greatly appreciated.

Thanks


Nov 19 '05 #3

P: n/a
Raja:

You can use some data binding syntax to set the hyperlink properties
from your datasource - that's just one possible solution.

Perhaps this might give you a tip:
http://odetocode.com/Articles/278.aspx

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 16 Feb 2005 07:31:12 -0800, "Raja"
<Ra**@discussions.microsoft.com> wrote:
Scott,
Thanks for your quick reply. This is very helpful. I have a further
question, hope you will be able to help me.

As I mentioned I have a grid and the gird 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:TemplateColumn>
<ItemTemplate>
<asp:ListBox
ID="ItemList" Runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="DropDown_SelectedIndexCha nged"/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:hyperlink runat='server' id='PocketDetails'/asp:hyperlink>
</ItemTemplate>
</asp:TemplateColumn>

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").

Please help me.

Thanks
Raja
"Scott Allen" wrote:
Raja:

I assume inside the grid definition you have something like:

<asp:TemplateColumn>
<ItemTemplate>
<asp:ListBox
ID="ItemList" Runat="server"
AutoPostBack="True"

OnSelectedIndexChanged="DropDown_SelectedIndexChan ged"/>
</ItemTemplate>
</asp:TemplateColumn>

The key is setting the AutoPostBack property to true and declaring an
event handler inside the tag. Then add an event handler in the code
behind - the sender parameter will be a reference to the ListBox.

Make sense?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 15 Feb 2005 11:49:01 -0800, "Raja"
<Ra**@discussions.microsoft.com> wrote:
>I have a simple question, I have a datagrid and inside the grid, i have List
>box. I am able to render the page with the datagrid and the lisbox values.
>Now, my question is how to trap the server side SelectedIndexChanged event of
>the listbox.
>
>Any help in VB.NET would be greatly appreciated.
>
>Thanks



Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.