如何将自定义radzendropdown项目设置为页面加载?

发布于 2025-01-27 13:08:40 字数 1297 浏览 4 评论 0原文

我已经在下面显示的代码中填充了Radzendropdown,

<RadzenDropDown @bind-Value="SomethingValueSelected" TValue="int" AllowFiltering="false" AllowClear="false" SelectedItem="0" SelectedItemsText="Test-1"
                        Data=@SomethingList TextProperty="Name" ValueProperty="Value"/>

这是带有填充项目的列表:

List<SomethingDTO> SomethingList= new List<SomethingDTO>(){ new SomethingDTO{ Name = "Test-1", Value = -1 },
                                                                                new SomethingDTO{ Name = "Test0", Value = 0 },
                                                                                new SomethingDTO{ Name = "Test1", Value = 1 },
                                                                                new SomethingDTO{ Name = "Test2", Value  = 2 },
                                                                                new SomethingDTO{ Name = "Test5", Value = 5 }};
int SomethingValueSelected;

这是我在页面加载时得到的:

I have populated a RadzenDropDown in the code shown below,

<RadzenDropDown @bind-Value="SomethingValueSelected" TValue="int" AllowFiltering="false" AllowClear="false" SelectedItem="0" SelectedItemsText="Test-1"
                        Data=@SomethingList TextProperty="Name" ValueProperty="Value"/>

Here is the list with populated items:

List<SomethingDTO> SomethingList= new List<SomethingDTO>(){ new SomethingDTO{ Name = "Test-1", Value = -1 },
                                                                                new SomethingDTO{ Name = "Test0", Value = 0 },
                                                                                new SomethingDTO{ Name = "Test1", Value = 1 },
                                                                                new SomethingDTO{ Name = "Test2", Value  = 2 },
                                                                                new SomethingDTO{ Name = "Test5", Value = 5 }};
int SomethingValueSelected;

And here is what i get when page loads:
enter image description hereenter image description here

My question is, how do I get automatically selected item called "Test-1", with the value of -1?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

软的没边 2025-02-03 13:08:40

好吧,这似乎很简单 -
只需将被束缚的元素的值设置为您喜欢的价值,就我而言是

int SomethingValueSelected = -1;

Well it seems like quite a simple one -
just set the value of element that is being binded to a value that you prefer, in my case it was

int SomethingValueSelected = -1;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文