C# DropDownList Asp.net的怪异行为

C# DropDownList Asp.net的怪异行为,c#,asp.net,drop-down-menu,C#,Asp.net,Drop Down Menu,我的DropDownListAsp.net中发生了奇怪的行为 我的代码: <asp:DropDownList ID="DDLFromMinutes" runat="server" Width="20%"> <asp:ListItem Text="00" Value="00"></asp:ListItem>

我的
DropDownList
Asp.net中发生了奇怪的行为

我的代码:

                 <asp:DropDownList ID="DDLFromMinutes" runat="server" Width="20%">
                                <asp:ListItem Text="00" Value="00"></asp:ListItem>
                                <asp:ListItem Text="15" Value="15"></asp:ListItem>
                                <asp:ListItem Text="30" Value="30"></asp:ListItem>
                                <asp:ListItem Text="45" Value="45"></asp:ListItem>
                            </asp:DropDownList>
代码隐藏:

string Frominput = seprateFromTime[1];
                string Frommin = Frominput.Substring(0, 2);
                DDLFromMinutes.SelectedItem.Text = Frommin;
                if (DDLFromMinutes.Items.Count > 0)
                {
                    DDLFromMinutes.SelectedIndex = DDLFromMinutes.Items.IndexOf(DDLFromMinutes.Items.FindByText(Frommin));
                }


保存数据时,请使用
DDLFromMinutes.SelectedItem.Text
这可能是个问题吗?

您需要使用MyDropDown.SelectedValue而不是SelectedItem.Text


此处的详细信息:

您需要使用MyDropDown.SelectedValue而不是selectedItem.Text


此处的详细信息:

是否要获取下拉列表的值?如果是这样,我认为您需要将SelectedItem更改为SelectedValue

是否要获取下拉列表的值?如果是这样,我认为您需要将SelectedItem更改为SelectedValue

请向我们展示您设置所选项目的代码隐藏。用户刚刚选择并保存数据的选择没有代码隐藏。我认为您需要重新格式化您的问题,因为我们无法理解。好的,我正在重新格式化我已经添加了我的代码。请向我们显示设置所选项目的代码。用户刚刚选择并保存数据的选择没有代码。我想你需要重新格式化你的问题,因为我们无法理解。好的,我正在重新格式化,我已经在后面添加了代码
string Frominput = seprateFromTime[1];
                string Frommin = Frominput.Substring(0, 2);
                DDLFromMinutes.SelectedItem.Text = Frommin;
                if (DDLFromMinutes.Items.Count > 0)
                {
                    DDLFromMinutes.SelectedIndex = DDLFromMinutes.Items.IndexOf(DDLFromMinutes.Items.FindByText(Frommin));
                }