DropDownList error when post back

Hello

I try to bind data to dropdownlist in formview control on postback.
After postback, it doesn't bind correctly.

I checked this forum.
https://www.syncfusion.com/forums/121710/dropdown-list-gets-empty-on-postback

Then, I added DataSourceCachingMode="ViewState" in dropdown list, but doesn't work.

I attach my code.  Could you please let me know what is wrong my code?


Thank you.
Yukiko

Attachment: postbackTest_dbdc5416.7z

9 Replies

PO Prince Oliver Syncfusion Team July 17, 2018 11:33 AM UTC

Hi Yukiko,   
  
Thank you for contacting Syncfusion Support.   
  
We can bind the data correctly to DropDownList after post back, when the “<%# Bind("memberId")%>” is removed from the value. On further investigation, we found that the issue is common in ASP.NET controls. So, we were able to find the following suggestions from the Microsoft’s blog. Kindly refer to the following links   
  
  
  
  

Regards, 
Prince 




YI Yukiko Imazu July 17, 2018 03:19 PM UTC

Hello Prince,

Thank you for your response.
We can't use those solution in our project because it will affect other functionality.

Anyway, we will think about another solution.

Thank you for your help.

Best Regards,
Yukiko




PO Prince Oliver Syncfusion Team July 18, 2018 10:14 AM UTC

Hi Yukiko, 

Thank you for your update. We regret that our solution did not help you, kindly let us know if you require any further assistance. 

Regards, 
Prince


YI Yukiko Imazu September 4, 2018 07:11 PM UTC

Hi

I have a question regarding value of dropdownlist.

In the previous response, it says

>We can bind the data correctly to DropDownList after post back, when the “<%# Bind("memberId")%>” is removed from the value. 

If <%# Bind("memberId")%>” is removed from the value, how can I set up value?

I attach sample solution that shows error when button was clicked.
I just want to achieve that when button was clicked (postback), memberId value should set as selected value in dropdownlist.

Thanks,
Yukiko

Attachment: postbackTest_a64da032.7z


KV Karthikeyan Viswanathan Syncfusion Team September 6, 2018 09:07 AM UTC

Hi Yukiko,    
   
Sorry for the inconvenience. 
 
We were unable to resolve this issue. Because of, it is a common issue in ASP.Net platform. We found the same issue is also occurred in common ASP.Net Controls. So, we suggest to remove the “<%# Bind("memberId")%>” in value property.  
   
Kindly refer to the following links    
   
   
   
   
 
Regards, 
Karthikeyan V. 




YI Yukiko Imazu September 6, 2018 12:46 PM UTC

Hi,

 >We were unable to resolve this issue. Because of, it is a common issue in ASP.Net platform.

We used to use common ASP.Net control on postback, we could use the same way without error.
Only when we switched to ej:dropdownlist, it appears error.  Even so, no way to resolve this issue?
We need to use same function as it used to be.  

I attached sample.  I commented out ejDropDownlist.

Thanks,
Yukiko

Attachment: postbackTest_2b3768a3.7z


KV Karthikeyan Viswanathan Syncfusion Team September 9, 2018 06:27 AM UTC

Hi Yukiko, 
 
We can use the session variable to pass the value from the code behind to the view page. Then use the control’s create event to set the value to the control. Kindly refer to the following code snippet. 

<ej:DropDownList ID="TitleCodeDropDownList" runat="server"   
                            Width="78" Height="20" DataSourceID="obj1" ClientSideOnCreate="oncreate"  DataTextField="year_of_service"  DataValueField="memberId" DataSourceCachingMode="ViewState"></ej:DropDownList> 
 
<script> 
    function oncreate() { 
        var value = <%= HttpContext.Current.Session("MyVariable").ToString()%>; 
        this.setModel({ value: value }); 
    } 
</script> 


Regards, 
Karthikeyan V. 



YI Yukiko Imazu September 11, 2018 04:48 PM UTC

Hi Karthikeyan,

Thank you for your support.
We could resolve our issue.

Regards,
Yukiko


KV Karthikeyan Viswanathan Syncfusion Team September 12, 2018 04:27 AM UTC

Hi Yukiko,  
 
Thanks for the update. 
 
We are glad to hear that your issue has been resolved. 
 
Regards, 
Karthikeyan V. 


Loader.
Up arrow icon