[求助]GridView中替换值送显
<asp:TemplateField HeaderText="性别"><ItemTemplate>
<asp:Image ID="imgshow" runat="server" ImageUrl='<% ... %>' />
</ItemTemplate>
</asp:TemplateField>
---------------------------------------------------------------------------------------------
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string unitsInStock = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "性别"));
if (unitsInStock == "男")
{
string showhel = "~/Images/sex1.gif";
}
else
{
string showhel = "~/Images/sex2.gif";
}
}
}
数据绑定后,性别的值是男\女,分别用图片 sex1.gif 和 sex2.gif 替换送显
[此贴子已经被作者于2007-9-11 0:10:25编辑过]