Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在gridview的单元格中设置方向_C#_Asp.net_Gridview_Direction - Fatal编程技术网

C# 如何在gridview的单元格中设置方向

C# 如何在gridview的单元格中设置方向,c#,asp.net,gridview,direction,C#,Asp.net,Gridview,Direction,我有一个gridview并绑定到数据集,用于在一列中显示价格,价格应按分隔,最后显示货币符号 protected void gvAirWaybill_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { double a = Convert.ToDouble(e.Row.Cells[11].Text.Tr

我有一个gridview并绑定到数据集,用于在一列中显示价格,价格应按分隔,最后显示货币符号

protected void gvAirWaybill_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
           double a = Convert.ToDouble(e.Row.Cells[11].Text.Trim());
           e.Row.Cells[11].Text = (a.ToString("C0", CultureInfo.CreateSpecificCulture("fa-IR")));
    }
}

但它先写入符号,然后写入价格。如何在运行时仅为此设置从左到右的方向?

尝试设置样式属性

e.Row.Cells[11].Style.Add("dir", "rtl");

如果要将所有gridview设置为从右向左,可以按如下方式声明gridview:

<asp:GridView ID="gvAirWaybill" runat="server" dir="rtl" >
...
</asp:GridView>

您可以创建一个CSS类

 .dir-rtl{
    direction:rtl;
}
然后在网格标记中将列的项目样式CssClass设置为您创建的CSS类

<ItemStyle CssClass="dir-rtl" />

你问过如何设置从左到右的方向!你是说从右向左吗?因为默认情况下,方向是从左到右