Editable DropDownList

  • Thread starter Thread starter Ian Oldbury
  • Start date Start date
I

Ian Oldbury

Hi

I need to place a DropDownList within the grid and have it editable when the
grid isn't in edit mode.
I've been able to place the control on the grid and have it working
including the postback.

However the problem that i'm experiencing is that i can't find out which row
the user is on.

I've included a sample of the code that i'm using....

thanks for your help.

ian

-- aspx page
<asp:templatecolumn headertext="Display Order">
<itemtemplate>
<asp:dropdownlist id="ddlDisplayOrder" runat="server"
onselectedindexchanged="ddlDisplayOrder_SelectedIndexChanged"
autopostback="True"></asp:dropdownlist>
</itemtemplate>
</asp:templatecolumn>


-- Code Behind

Public Sub ddlDisplayOrder_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ddlDisplayOrder.SelectedIndexChanged



End Sub
 
You might try sticking the item index into the name attribute; something like:

name='<%# Container.ItemIndex %>'

Then reading the name attribute on the postback.
 
I take it back; you can't use the name...I think the last time I did this, I wrote an item create
method and tacked the item index onto the name of the control -- but I've already been wrong once.

Scott
 
Thanks for your reply Scott.
i originally posted the problem on the
microsoft.public.dotnet.framework.aspnet.datagridcontrol newsgroup if
thats a useful resource for you.

It can be a little devil finding the ideal/best way for these little
problems, so i don't have a clue if this is the right way!

One idea was to prefixing the row number into the non viewable element
of the dropdownlist using a delimiter.

However as often seems to be the way for me an idea came to me last
night....

Public Sub ddlDisplayOrder_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ddlDisplayOrder.SelectedIndexChanged
sender.bindingcontainer.itemindex
End Sub
 
Back
Top