我的网页只与部分下拉列表产生了问题。如上所示,autopostback = true,是的,我正在考虑!回发。
业务线,董事和代理人都没有发布任何问题,但高级经理和经理回复列表中的第一个值,无论选择如何。
这是asp
<asp:TableRow>
<asp:TableCell CssClass="tc1" Width="17%">
<asp:Label ID="lblLob" runat="server">Line Of Business: </asp:Label>
</asp:TableCell>
<asp:TableCell CssClass="tc1">
<asp:DropDownList ID="cmbLoB" runat="server" AutoPostBack="true" OnSelectedIndexChanged="reSelect"></asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvLoB" runat="server" ControlToValidate="cmbLoB" InitialValue="0" ErrorMessage="Please select a Line of Business"></asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ID="tcRange" CssClass="tc1" runat="server" Width="15%">
<asp:Label ID="lblDateRange" runat="server">Report Range: </asp:Label>
</asp:TableCell>
<asp:TableCell CssClass="tc1">
<asp:DropDownList ID="cmbDateRange" runat="server" AutoPostBack="true" OnSelectedIndexChanged="reSelect"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell CssClass="tc1"><asp:Label ID="lblStartDate" runat="server" Text="Start Date: "></asp:Label></asp:TableCell>
<asp:TableCell CssClass="tc2"><asp:TextBox ID="txtStartDate" runat="server" AutoPostBack="true"></asp:TextBox><asp:CalendarExtender
ID="calStartDate" runat="server" TargetControlID="txtStartDate" Format="yyyy-MM-dd">
</asp:CalendarExtender>
</asp:TableCell>
<asp:TableCell CssClass="tc1"><asp:Label ID="lblEndDate" runat="server" Text="End Date: "></asp:Label></asp:TableCell>
<asp:TableCell CssClass="tc2"><asp:TextBox ID="txtEndDate" runat="server" AutoPostBack="true"></asp:TextBox><asp:CalendarExtender
ID="calEndDate" runat="server" TargetControlID="txtEndDate" Format="yyyy-MM-dd"></asp:CalendarExtender>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell CssClass="tc1" Width="17%">
<asp:Label ID="lblDirector" runat="server">Senior Leader: </asp:Label>
</asp:TableCell>
<asp:TableCell CssClass="tc1">
<asp:DropDownList ID="cmbDirector" runat="server" AutoPostBack="true" OnSelectedIndexChanged="reSelect"></asp:DropDownList>
</asp:TableCell>
<asp:TableCell CssClass="tc1" Width="17%" ID="tdlblAggregate" runat="server" Visible="false">
<asp:Label ID="lblAggregate" runat="server">Aggregation Level: </asp:Label>
</asp:TableCell>
<asp:TableCell CssClass="tc1" ID="tdcmbAggregate" runat="server" Visible="false">
<asp:DropDownList ID="cmbAggregate" runat="server" AutoPostBack="true" OnSelectedIndexChanged="reSelect">
<asp:ListItem Value="LoB" Text="Segment"></asp:ListItem>
<asp:ListItem Value="SM" Text="Senior Manager"></asp:ListItem>
</asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell CssClass="tc1">
<asp:Label ID="lblSManager" Visible="true" runat="server">Senior Manager: </asp:Label>
</asp:TableCell>
<asp:TableCell CssClass="tc1">
<asp:DropDownList ID="cmbSManager" runat="server" AutoPostBack="true" OnSelectedIndexChanged="reSelect"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell CssClass="tc1">
<asp:Label ID="lblManager" Visible="true" runat="server">Manager: </asp:Label>
</asp:TableCell>
<asp:TableCell CssClass="tc1">
<asp:DropDownList ID="cmbManager" runat="server" AutoPostBack="true" OnSelectedIndexChanged="reSelect"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell CssClass="tc1">
<asp:Label ID="lblAgent" Visible="true" runat="server">Associate/Specialist: </asp:Label>
</asp:TableCell>
<asp:TableCell CssClass="tc1">
<asp:DropDownList ID="cmbAgent" runat="server" AutoPostBack="true" Visible="true" OnSelectedIndexChanged="reSelect"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
背后的代码:
DataTable SLTSelectDistinct = SLTSelect.DefaultView.ToTable(true, "sltID", "sltName");
DataView sltSelect = new DataView(SLTSelectDistinct);
DataRow sltRow = SLTSelectDistinct.NewRow();
sltRow[0] = "0";
sltRow[1] = "-- Please Select --";
SLTSelectDistinct.Rows.Add(sltRow);
sltSelect.Sort = "sltName";
cmbDirector.DataValueField = "sltID";
cmbDirector.DataTextField = "sltName";
cmbDirector.DataSource = sltSelect;
cmbDirector.DataBind();
DataTable SMSelectDistinct = SMSelect.DefaultView.ToTable(true, "smID", "smName");
DataView smSelect = new DataView(SMSelectDistinct);
DataRow smRow = SMSelectDistinct.NewRow();
smRow[0] = "0";
smRow[1] = "-- Please Select --";
SMSelectDistinct.Rows.Add(smRow);
smSelect.Sort = "smName";
cmbSManager.DataValueField = "smID";
cmbSManager.DataTextField = "smName";
cmbSManager.DataSource = smSelect;
cmbSManager.DataBind();
DataTable MSelectDistinct = MSelect.DefaultView.ToTable(true, "mID", "mName");
DataView mSelect = new DataView(MSelectDistinct);
DataRow mRow = MSelectDistinct.NewRow();
mRow[0] = "0";
mRow[1] = "-- Please Select --";
MSelectDistinct.Rows.Add(mRow);
mSelect.Sort = "mName";
cmbManager.DataValueField = "mID";
cmbManager.DataTextField = "mName";
cmbManager.DataSource = mSelect;
cmbManager.DataBind();
DataTable ASelectDistinct = LoBSelect.DefaultView.ToTable(true, "C_AGT", "aName");
DataView aSelect = new DataView(ASelectDistinct);
DataRow aRow = ASelectDistinct.NewRow();
aRow[0] = "0";
aRow[1] = "-- Please Select --";
ASelectDistinct.Rows.Add(aRow);
aSelect.Sort = "aName";
cmbAgent.DataValueField = "C_AGT";
cmbAgent.DataTextField = "aName";
cmbAgent.DataSource = aSelect;
cmbAgent.DataBind();
答案 0 :(得分:0)
你可能有0作为你的一个实际选项的值,所以当页面刷新时,下拉列表的选定值为0,这也恰好是默认值&#34; Select One& #34;选项。