capture dropdownlist in edit mode autopostback

J

James

I have a datagrid that in edit mode shows a dropdownlist. I need to be able
to postback and manipulate some of the edit template controls depending on
what the user selected in the dropdown. I was hoping to be able to
autopostback and capture the selected index changed event of the dropdown,
but I can't figure out how to do this. The itemcommand event doesn't fire
on the postback, and I can't wire up the dropdown's selectedindexchanged
since its within the datagrid. Anyone know how to do this?
 
Y

Yan-Hong Huang[MSFT]

Hello James,

Here's a great datagrid article by Dino Esposito that includes a dropdownlist. It might give you an idea.

http://msdn.microsoft.com/msdnmag/issues/01/06/cutting/cutting0106.asp

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "James" <[email protected]>
!Subject: capture dropdownlist in edit mode autopostback
!Date: Sat, 12 Jul 2003 13:53:20 -0400
!Lines: 9
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <#[email protected]>
!Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
!NNTP-Posting-Host: pcp02425703pcs.howard01.md.comcast.net 68.55.90.155
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.datagridcontrol:5667
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
!
!I have a datagrid that in edit mode shows a dropdownlist. I need to be able
!to postback and manipulate some of the edit template controls depending on
!what the user selected in the dropdown. I was hoping to be able to
!autopostback and capture the selected index changed event of the dropdown,
!but I can't figure out how to do this. The itemcommand event doesn't fire
!on the postback, and I can't wire up the dropdown's selectedindexchanged
!since its within the datagrid. Anyone know how to do this?
!
!
!
 
L

Luke Zhang [MSFT]

First, you need to set the DropDownList's OnSelectedIndexChanged to a
function in the code behind:

<EditItemTemplate >
<asp:DropDownList id="DropDownList1" runat="server"
AutoPostBack ="True" OnSelectedIndexChanged
="DropDownList1_SelectedIndexChanged" >
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>

Then in the funtion:

Public Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged


Response.Write(DataGrid1.Items(DataGrid1.EditItemIndex).Controls.Count)

End Sub

HTH

Luke

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top