Ik heb het volgende probleem, ik heb een applicatie waarbij ik wedstrijden op kan voeren. Afhankelijk van de gekozen poule (ddlWedstrijdPoule) moeten de opties voor de thuisteams (TeamDropDownThuis) aangepast worden. Bij het opstarten gaat het goed, als ik de poule wijzig krijg ik deze fout:
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
Mijn asp:
Code behind:
Custom dropdownlists:
Iemand een idee hoe dit op te lossen is.
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
Mijn asp:
ASP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| <asp:FormView SkinID="FormView" ID="formViewWedstrijd" runat="server" DataSourceID="odsWedstrijd" DataKeyNames="WedstrijdId" EnableViewState="false" OnItemUpdating="FormViewWedstrijd_ItemUpdating" OnItemInserting="FormViewWedstrijd_ItemInserting" OnDataBound="FormViewWedstrijd_DataBound"> <EditItemTemplate> <table width="560" id="tblEditWed"> <tr> <td class="datafieldTBL"> <CustomControl:PouleDropDown SelectedValue='<%# Bind("poulecode") %>' runat="server" ID="ddlWedstrijdPoule" OnDataBound="PouleDropDown_DataBound" OnSelectedIndexChanged="PouleDropDown_SelectedIndexChanged" AutoPostBack="true" ValidationProperty="Value"> </CustomControl:PouleDropDown> </td> </tr> <tr> <td class="captionTBL"> <span class="requiredLabelCaptionTBL">* </span>Thuis: </td> <td class="spacerTBL"> </td> <td class="datafieldTBL" align="left"> <CustomControl:PouleTeamDropDown SelectedValue='<%# Bind("thuisteamId") %>' runat="server" OnSelectedIndexChanged="thuisteamChanged" ID="TeamDropDownThuis" AutoPostBack="true"> </CustomControl:PouleTeamDropDown> </td> </tr> </table> </EditItemTemplate> </asp:FormView> |
Code behind:
C#:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| protected void PouleDropDown_DataBound(object sender, EventArgs e) { DropDownList ddl = (DropDownList)formViewWedstrijd.FindControl("ddlWedstrijdPoule"); if (ddl.SelectedItem != null) { Utilities.PouleTeamDropDown.vulTeams(ddl.SelectedItem.Text); } } protected void PouleDropDown_SelectedIndexChanged(object sender, EventArgs e) { DropDownList ddl = (DropDownList)formViewWedstrijd.FindControl("ddlWedstrijdPoule"); if (ddl.SelectedItem != null) { Utilities.PouleTeamDropDown.vulTeams(ddl.SelectedItem.Text); DropDownList ddlThuis = (DropDownList)formViewWedstrijd.FindControl("TeamDropDownThuis"); ddlThuis.DataBind(); DropDownList ddlUit = (DropDownList)formViewWedstrijd.FindControl("TeamDropDownUit"); ddlUit.DataBind(); } } |
Custom dropdownlists:
C#:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
| [SupportsEventValidation, ValidationProperty("SelectedItem")] [ToolboxData("<{0}:PouleDropDown runat=server></{0}:PouleDropDown>")] public class PouleDropDown : DropDownList { public override void DataBind() { CustomCollection<Poule> poules = PoulesCL.SelectAllPouleCodes(); DataSource = poules; DataTextField = "poulecode"; DataValueField = "poulecode"; base.DataBind(); } string _poulecode = ""; public string Poulecode { get { return _poulecode; } set { _poulecode = Text; } } } [SupportsEventValidation, ValidationProperty("SelectedItem")] [ToolboxData("<{0}:PouleTeamDropDown runat=server></{0}:PouleTeamDropDown>")] public class PouleTeamDropDown : DropDownList { private static CustomCollection<Poule> pouleTeams; public static void vulTeams(string poulecode) { pouleTeams = PoulesCL.SelectAllPouleTeams(poulecode); } public override void DataBind() { if (pouleTeams != null) { DataSource = pouleTeams; DataTextField = "club"; DataValueField = "pouleId"; base.DataBind(); } } string _pouleTeam = ""; public string PouleTeam { get { return _pouleTeam; } set { _pouleTeam = value; } } } |
Iemand een idee hoe dit op te lossen is.