在我的 EditTemplate 中,我有一个 DropDownList :
<EditItemTemplate>
<asp:DropDownList ID="ddlFixture" runat="server" AutoPostBack="True" onselectedindexchanged="fixtureSelected"
DataSourceID="FixtureDataSource" DataTextField="WTag" DataValueField="WTag" AppendDataBoundItems="true" SelectedValue='<%#Bind("Fixure") %>'>
</asp:DropDownList>
</EditItemTemplate>
当用户从 DropDownList 中选择一个项目时,我也喜欢填充 EditMode 中的其他字段。
您会注意到在 onselectedindexchanged="fixtureSelected" 上我调用的是fixtureSelected。我已经注意到我面临的一些问题:
protected void fixtureSelected(object sender, EventArgs e)
{
// Below I am trying to get value of ddlFixture but it cannot recognize ddlFixture. GettingThe name 'ddlFixture' does not exist in the current context
string fixtureId = ddlFixture.SelectedItem.Value;
// I also need to update the text in EditMode but this will not work either. Get similar message as for ddlFixture
txtCampus.Text = "Campus1";
}