在我的gridview中,有一个以'Price'为标题的列作为标题文本。我需要添加'Rs'。在该列中所有单元格值的开头。
这是我的Gridview ..
<asp:GridView ID="gridViewStock" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="UCP" ItemStyle-Width="14%">
<ItemTemplate>
<asp:Label ID="lblPrice" runat="server" Text='<%# Eval("Price") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</cloumns>
</GridView>
请帮助。提前致谢
答案 0 :(得分:2)
使用代码隐藏,RowDataBound
是正确的事件:
protected void gridViewStock_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblPrice = (Label) e.Row.FindControl("lblPrice");
lblPrice.Text = "Rs." + lblPrice.Text;
}
}