Hello Experts:
I previously had some help with getting a value of a drop down list when a datagrid is edited. Here is the code I ended up using that works fine inside my datagrid:
<asp:dropdownlist id="ddlAppt" style="Z-INDEX: 139; LEFT: 536px; POSITION: absolute; TOP: 232px" Width="152px"
Runat="server" DataTextField="Appt" DataValueField="Appt" SelectedIndex='<% #DgDD5GetIDX(Container.Dat
aItem("App
t")) %>'>
<asp:ListItem Value=' ' />
<asp:ListItem Value='Yes' />
<asp:Listitem Value='No' />
</asp:dropdownlist>
code-behind:
Function DgDD5GetIDX(ByVal Val As Object) As Integer
If Not (Val Is Nothing) Then
Select Case Val
Case "Yes"
Return 1
Case "No"
Return 2
Case Else
Return 0
End Select
Else
Return 0
End If
End Function
This is just a plain form I use for user input to a data table in sql. This isn't in use inside a datagrid so I'm sure it needs some changing to work on a plain form.
This is the error I get:
Compiler Error Message: BC30456: 'DataItem' is not a member of 'System.Web.UI.Control'.
Source Error:
Line 39: tabIndex="6" runat="server"></asp:textb
ox><asp:te
xtbox id="TextBoxInterested" style="Z-INDEX: 107; LEFT: 208px; POSITION: absolute; TOP: 296px"
Line 40: tabIndex="5" runat="server"></asp:textb
ox>
Line 41: <asp:dropdownlist id="ddlSold" style="Z-INDEX: 106; LEFT: 536px; POSITION: absolute; TOP: 328px" tabIndex="15"
Line 42: runat="server" Width="152px" SelectedIndex='<% #DgDD1GetIDX(Container.Dat
aItem("Sol
d")) %>'>
Line 43: <asp:ListItem Value=' ' />
Source File: c:\inetpub\wwwroot\SLN\Web
Form1.aspx
Line: 41
So I just want to see the value of the drop down list when I record is retrieved into this form. It has 5 drop down lists in all. They all only have 2 - 3 selections, so the person who originally helped me thought this method was the easiest. Help?!
Thanks
Start Free Trial