2016-05-31 55 views
0

我有一個表格,其中每行都有一個數字。我想這個行數必須與字體風格:大膽ASP.NET - 字符串中的前2個字符必須是粗體

這是我的代碼:

DataTable table = new DataTable(); 
table.Columns.Add("Route"); 

int counter = 1; 
foreach (SPListItem item in myItemColForTable) 
{ 
    DataRow row = table.NewRow(); 
    row["Route"] = counter.ToString() + ". " + item["Route"].ToString(); 
    counter ++; 
} 

DataView mydataview = new DataView(table); 
table = mydataview.ToTable(true, "Route"); 
myGrid.DataSource = table; 
myGrid.DataBind(); 

我想這個字符串 - >

counter.ToString ()+「。」

必須與加粗風格。

回答

1

那麼您可以拉出文本,並用粗體選項打開的跨度替換它。

實施例:

void Item_Bound(Object sender, DataGridItemEventArgs e) 
{ 
    string yourSubString = "some string to bold"; 
    e.Item.Cells[0].Text = e.Item.Cells[0].Text.Replace(yourSubString, 
     string.Format("<span style='font-weight: bold'>{0}</span>", yourSubString)); 

} 
+0

這是可能的,而不活動? – Gohyu

+0

是的。有可能的。 – SSJGSS

+0

幫我用我的代碼,我是初學者做這個.. – Gohyu

相關問題