在我的网格视图中,有一列带有“价格”作为标题文本。我需要添加“ 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>
请帮忙。提前致谢
使用codebehind,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;
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句