从后面的代码中向Gridview添加属性

时间:2016-04-11 15:35:19

标签: c# datatables

尝试对数据表使用分页,我想翻译Dropdown所以它用法语表示All或Tous。我试图将其作为属性添加到Gridview中,但引号显示为& quot,它们不会呈现。

我需要这个 data-wb-tables =' {" aLengthMenu":[[5,10,25,50,-1],[5,10,25,50," All&#34 ;]," iDisplayLength":15,"订购":true,"订单":[0," desc" ]," paging":true," info":true,"搜索":false}'

但我得到了这个

data-wb-tables="{ "aLengthMenu": [[5,10, 25, 50, -1], [5,10, 25, 50, "All"]], "iDisplayLength": 15, "ordering": true, "order": [ 0, "desc" ], "paging": true, "info": true, "searching": false }" 

 protected void grdAllRequests_PreRender(object sender, EventArgs e)
{
    grdAllRequests.Attributes.Add("data-wb-tables", grdAllRequestsPagingText());
}

    private string grdAllRequestsPagingText()
{
    //Not implemented yet
    //string localisedText = SiteInfo.IsFrench ? "Tous les" : "All";

    return string.Format("{0}", "'{ \"aLengthMenu\": [[5,10, 25, 50, -1], [5,10, 25, 50, \"All\"]], \"iDisplayLength\": 15, \"ordering\": true, \"order\": [ 0, \"desc\" ], \"paging\": true, \"info\": true, \"searching\": false }'");
}

1 个答案:

答案 0 :(得分:2)

试试这个:

    data-wb-tables=@"{""aLengthMenu"": [[5,10, 25, 50, -1], [5,10, 25, 50, ""All""]], ""iDisplayLength"": 15, ""ordering"": true, ""order"": [ 0, ""desc"" ], ""paging"": true, ""info"": true, ""searching"": false }";
protected void grdAllRequests_PreRender(object sender, EventArgs e)
{
    grdAllRequests.Attributes.Add("data-wb-tables",data-wb-tables);
}