Question

I'm getting very weird error on the page on every other refresh but NOT every time.

I have a simple page printing out the data as follow:

Backend(aspx.cs)

string sql="Select * from content_mgr_multiple where category = '1' limit 0, 1";    
DataView dv = DBAccess.GetListView(sql);
this.ResultList.DataSource = dv;
this.ResultList.DataBind();

Frontend(aspx)

<asp:Repeater ID="ResultList" runat="server">
<ItemTemplate>
     <%#  Eval("content") %>
</ItemTemplate>
</asp:Repeater>

The code work as simple as above but it is showing the following error for every other refresh. DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'content'.

Let's say I refresh the page 6 times. 2nd,4th and 6th time are fine but 1st,3rd and 5th time are showing above error.

I tried to troubleshoot as follow. I put codes to print out the column names in that DataSource.

string sql="Select * from content_mgr_multiple where category = '1' limit 0, 1";    
DataView dv = DBAccess.GetListView(sql);
        foreach (DataColumn dr in dv.Table.Columns)
        {
            Response.Write(dr.ColumnName + "<BR>");
        }
this.ResultList.DataSource = dv;
this.ResultList.DataBind();

On 2nd,4th and 6th time refresh, the column names are printed out in English.

id
category
title
titleCh
content
contentCh

On 1st,3rd and 5th time refresh, the column names are printed out in Chinese.

楤
捡瑥杯特
瑩瑬�
瑩瑬敃�
捯湴敮�
捯湴敮瑃�

I have been fighting this for a while and please help. Thanks.

Was it helpful?

Solution

Thank you guys very much for your concern. Finally, I found what was causing it. As eggyal pointed out, it made me realize that something was wrong with the database.

I have content_mgr category table which is holding Chinese titles too. In that category table, the Chinese filed was created as "ucs2_general_ci". As soon as I changed it to "utf8_general_ci", the problem is solved.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top