我是 c# 和 asp.net 的新手。我有一个GridView
与某些记录。When any record is chosen it is displayed in the DetailsView
. 我的详细信息视图有 3 DropDownLists
。在我的详细信息视图的编辑模式中,当我在下拉列表中更改我的选择并更新它时,特定字段采用空值。我用过OnSelectedIndexChanged
,我确信它会被触发,但值为空。这是我的代码。
protected void DropDownList1_SelectedIndexChanged(object sender,EventArgs e)
{
DropDownList ddl = (DropDownList)this.form1.FindControl("DropDownList1");
hi.Visible = true;
if (ddl != null)
{
ddl.Text = ddl.SelectedItem.Value;
ddl.DataBind();
}
}
我也尝试过使用该SelectedValue
属性进行更新,但这也没有用。
<asp:DropDownList ID="DropDownList1" DataTextField="strCollegeLongName"
DataValueField="strCollegeLongName" runat="server"
DataSourceID="SqlDataSource1" autoPostBack="true" AppendDataBoundItems="false"
SelectedValue='<%#Bind="College">%'>
</asp:DropDownList>
UpdateCommand="UPDATE [RegistrationFormInfo] SET [FirstName]=@FirstName,
[LastName]=@LastName,[EmailAddress]=@EmailAddress,[GradDate]=@GradDate,
[WorkAuth]=@WorkAuth,[Address]=@Address,[Phone]=@Phone,[UFID]=@UFID,
[GatorAcct]=@GatorAcct,[College]=@College,[Major]=@Major,[UserType]=@UserType,
[AdminUser]=@AdminUser,[blnActive]=@blnActive,[EntryTS]=@EntryTS WHERE [Guid]=@Guid "
所以,这里它会抛出一个错误@College
,说不存在,但我的表有College
列。
我被卡住了,任何帮助将不胜感激!