在gridview中显示波斯数字 [英] display Persian number in gridview

查看:88
本文介绍了在gridview中显示波斯数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个GridView,其中包含一些从数据库读取的值.
我想用波斯语给他们看.
这是我的代码:

Hi,
I have a GridView with some values which are read from database.
I want to show them in persian.
This is my code :

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataKeyNames="GroupId" DataSourceID="SqlDataSource1">
         <Columns>
             <asp:BoundField DataField="GroupId" HeaderText="GroupId" ReadOnly="True" 
                 SortExpression="GroupId" />
             <asp:BoundField DataField="<%=ToFarsi('ParentGroupId')%>"
                 HeaderText="ParentGroupId" 
                 SortExpression="ParentGroupId" />
             <asp:BoundField DataField="GroupName" HeaderText="GroupName" 
                 SortExpression="GroupName" />
         </Columns>
     </asp:GridView>


<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:dbtestConnectionString2 %>" 
            SelectCommand="SELECT * FROM [T_group]"></asp:SqlDataSource>



我的方法:



And my method :

public static string ToFarsi(string str)
   {
       string vInt = "1234567890";
       char[] mystring = str.ToCharArray(0, str.Length);
       var newStr = string.Empty;
       for (var i = 0; i <= (mystring.Length - 1); i++)
           if (vInt.IndexOf(mystring[i]) == -1)
               newStr += mystring[i];
           else
               newStr += ((char)((int)mystring[i] + 1728));
       return newStr;
   }




这是错误:
在选定的数据源上找不到名称为<%= ToFarsi(``ParentGroupId'')%>''的字段或属性.




This is the error :
A field or property with the name ''<%=ToFarsi(''ParentGroupId'')%>'' was not found on the selected data source.

推荐答案

ConnectionStrings:dbtestConnectionString2%> SelectCommand ="SELECT * FROM [T_group]"></asp:SqlDataSource>
ConnectionStrings:dbtestConnectionString2 %>" SelectCommand="SELECT * FROM [T_group]"></asp:SqlDataSource>



我的方法:



And my method :

public static string ToFarsi(string str)
   {
       string vInt = "1234567890";
       char[] mystring = str.ToCharArray(0, str.Length);
       var newStr = string.Empty;
       for (var i = 0; i <= (mystring.Length - 1); i++)
           if (vInt.IndexOf(mystring[i]) == -1)
               newStr += mystring[i];
           else
               newStr += ((char)((int)mystring[i] + 1728));
       return newStr;
   }




这是错误:
在所选数据源上找不到名称为<%= ToFarsi(``ParentGroupId'')%>''的字段或属性.




This is the error :
A field or property with the name ''<%=ToFarsi(''ParentGroupId'')%>'' was not found on the selected data source.


hi
数据字段的值将检查要绑定的选定列"名称,此ID中没有列<%= ToFarsi("ParentGroupId")%>"
多数民众赞成为什么要列出该错误

我认为您必须找出其他方法来进行转换,现在您正在尝试从Datagrid DataField本身进行转换...
hi
The Data Filed values will check the Selected Column names which you are going to bind there is no column in this ID "<%=ToFarsi(''ParentGroupId'')%>"
thats why its listing that error

I think you have to figure out some other methods to Conversion now you are trying to Convert it from the Datagrid DataField itself...


我已经回答了有关东部阿拉伯数字"的问题,但是波斯语的变体有点不同,如下所述:

http://en.wikipedia.org/wiki/Eastern_Arabic_numerals [ asp.net中的阿拉伯数字问题 [ ^ ].

我的代码类似于您的ToFarsi,只需检查一下即可.

您可能需要修复此实现才能修复波斯数字.我无法弄清楚Unicode代码点和波斯数字变体之间的映射关系,但是映射关系可能不仅是平移(排序可以是非线性的).请使用 http://unicode.org/ [ ^ ]进行查找.

—SA
I already answered this question about "Eastern Arabic Numerals", but Persian variant is a bit different, as described here:

http://en.wikipedia.org/wiki/Eastern_Arabic_numerals[^].

So the implementation could be a bit more complex but the idea is basically the same.

So, please see my past solution for Eastern Arabic:
Arabic number problem in asp.net[^].

My code is similar to your ToFarsi, just check it up.

You may need to fix this implementation to fix the Persian numerals. I could not figure out the mapping between Unicode code points and Persian variant of numerals, but it''s possible that the mapping is not just the shift (ordering can be non-linear). Please use http://unicode.org/[^] to find out.

—SA


这篇关于在gridview中显示波斯数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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