下拉值不正确 [英] Dropdown values are not correct

查看:70
本文介绍了下拉值不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我这段代码有什么问题.

Please tell me what is wrong in this code.

<asp:DropDownList ID="ddlFromYear" runat="server" SkinID="DDLSmall">
                                                                    <asp:ListItem Text='<%= System.DateTime.Now.Year %>' Value="1"></asp:ListItem>
                                                                    <asp:ListItem Text='<%= System.DateTime.Now.Year-1 %>' Value="2"></asp:ListItem>
                                                                </asp:DropDownList>




我没有得到年份,而是在运行时打印表达式.

谢谢,
Jagjot




I am not getting year, it is printing the expression at runtime.

Thanks,
Jagjot

推荐答案

您不能尝试在下拉菜单中插入ListItems吗?
试试这个:
Can''t you try with inserting the ListItems in for the dropdown?
Try this:
ddlFromYear.Items.Insert(0, new ListItem(System.DateTime.Now.Year.ToString(), "1"));
ddlFromYear.Items.Insert(1, new ListItem((System.DateTime.Now.Year-1).ToString(), "2"));



--Amit



--Amit


这篇关于下拉值不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆