ComboBox rendered after postback in ItemsControl resets selected value
See original GitHub issueHi guys, when I fill list ‘FirstList’ with data after postback and content of repeater (same for gridview) is rendered, comboboxes resets selected values to value of first item in ‘FirstList’.
HTML:
<dot:Button Text="Postback" Click="{command: DoPostback()}" />
<dot:Repeater DataSource="{value: FirstList}">
<ItemTemplate>
<dot:ComboBox SelectedValue="{value: SelectedValue}" DisplayMember="Text" ValueMember="Value" DataSource="{value: _parent.SecondList}">
</dot:ComboBox>
Selected: {{value: SelectedValue}}
</ItemTemplate>
</dot:Repeater>
CS:
public class TestPageViewModel: DotvvmViewModelBase
{
public List<FirstListItem> FirstList { get; set; } = new List<FirstListItem>();
public List<SecondListItem> SecondList { get; set; } = new List<SecondListItem>();
public void DoPostback()
{
FirstList = new List<FirstListItem>()
{
new FirstListItem() { SelectedValue = 1 },
new FirstListItem() { SelectedValue = 2 }
};
SecondList = new List<SecondListItem>()
{
new SecondListItem() { Text = "Value1", Value = 1 },
new SecondListItem() { Text = "Value2", Value = 2 }
};
}
}
public class SecondListItem
{
public int Value { get; set; }
public string Text { get; set; }
}
public class FirstListItem
{
public int SelectedValue { get; set; }
}
Result after postback (click):
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Drop Down List Selected Value Gets Reset On PostBack ...
1 Answer 1 ... You can remove the Autopostback="True" so that no postbacks takes place.. ... Autopostback="True" is set whenever you have to...
Read more >Radcombobox not retaining selected value after postback
The Radcomboxes are losing selected values after postback. Is there a way to retain selected values in a Radcombobox across postbacks?
Read more >ASPxComboBox resets value upon postback when ...
Open page; The second item is selected [correct] · Select any other item; press "Postback". The new value stays after the postback [correct] ......
Read more >Runtime Changes for Migration from .NET Framework 4.5.1 ...
NET Framework 4.5 causes values set via a null coalescing operation to not be visible in the debugger immediately after the assignment operation ......
Read more >Dropdownlist gets reset after postback.
All items are added perfectly but when I want to add selected value from that in DB,On clicking button the dropdownlist gets reset...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Works like a charm, thx guys!
OK, we’ll dig into this and fix it.