Listbox inside a DataGrid

G

Guest

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
 
S

Scott Allen

Raja:

I assume inside the grid definition you have something like:

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

OnSelectedIndexChanged="DropDown_SelectedIndexChanged"/>
</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?
 
G

Guest

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_SelectedIndexChanged"/>
</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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top