Here you go, I've included the other bits which could be the culprit as
well.
Many thanks for your help,
Sam
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If Session("user") Is Nothing Then
Response.Redire ct("Default.asp x")
End If
If Not Page.IsPostBack Then
PopulateForm()
End If
End Sub
Private Sub dgrdParticipant s_ItemDataBound (ByVal sender As System.Object,
ByVal e As DataGridItemEve ntArgs) Handles dgrdParticipant s.ItemDataBound
'add the client side confirmation for the delete link
If e.Item.ItemType <> ListItemType.He ader AndAlso e.Item.ItemType <>
ListItemType.Fo oter AndAlso e.Item.ItemType <> ListItemType.Ed itItem Then
Dim deleteButton As LinkButton =
e.Item.Cells(6) .FindControl("l nkDeletePartici pant")
Dim oParticipant As cParticipant = e.Item.DataItem
deleteButton.At tributes("oncli ck") = "javascript
:ret urn confirm('Delete " &
oparticipant.Fo rename & " " & oparticipant.Su rname & "?')"
End If
'load the combo boxes
'if the row is the one being edited
If e.Item.ItemType = ListItemType.Ed itItem Then
Dim oParticipant As cParticipant = e.Item.DataItem
Dim cboGender As DropDownList = e.Item.Cells(3) .Controls(1)
cboGender = LoadGenders(cbo Gender, oParticipant.Ge nderID)
Dim cboTicketType As DropDownList = e.Item.Cells(5) .Controls(1)
cboTicketType = LoadTicketTypes (cboTicketType, oParticipant.Ti cketTypeID)
End If
'if the row is the footer
If e.Item.ItemType = ListItemType.Fo oter Then
Dim cboTicketType As DropDownList = e.Item.Cells(5) .Controls(1)
cboTicketType = LoadTicketTypes (cboTicketType)
Dim cboGender As DropDownList = e.Item.Cells(3) .Controls(1)
cboGender = LoadGenders(cbo Gender)
End If
End Sub
Private Function LoadTicketTypes (ByVal cboTicketType As DropDownList,
Optional ByVal currentValue As Int32 = -1) As DropDownList
Dim oTicketType As cTicketType
Dim liItem As ListItem
For Each oTicketType In cTicketTypes.Cr eateNew(Session ("group").Ca mp)
liItem = New ListItem
liItem.Text = oTicketType.ToS tring
liItem.Value = oTicketType.ID. ToString
cboTicketType.I tems.Add(liItem )
Next
cboTicketType.I D = "cboTicketT ype"
SetDropDownSele cted(cboTicketT ype, currentValue)
Return cboTicketType
End Function
Private Sub SetDropDownSele cted(ByVal ddl As DropDownList, ByVal value As
String)
Dim li As ListItem
li = ddl.Items.FindB yValue(value)
If Not li Is Nothing Then
ddl.SelectedInd ex = ddl.Items.Index Of(li)
End If
End Sub
"gaidar" <ga****@vbstree ts.ru> wrote in message
news:ew******** ******@TK2MSFTN GP09.phx.gbl...
Could you post Page_Load code here?
Gaidar
"Sam C" <th***********@ yahoo.co.uk> wrote in message
news:42******** *************** @ptn-nntp-reader01.plus.n et... Hi,
I have an ASP.Net page which has a DropDownList on it. The DDL is
populated via a method which is called from the Page_Load if IsPostBack =
False.
When the form is submitted the SelectedItem of the DDL (as retrieved from
any of the supplied methods) is always the top item regardless of which
one is actually selected. The odd thing is that any resubmissions of the
form produce the correct SelectedItem.
Any ideas?
Sam