前台代码
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowPaging="True"
PageSize="14" OnPageIndexChanging="GridView1_PageIndexChanging" OnRowDataBound="GridView1_RowDataBound"
SelectedRowStyle-BorderColor="Blue" SelectedRowStyle-Font-Bold="true"
SelectedRowStyle-Font-Size="Larger"
>
<Columns>
<asp:BoundField DataField="number" HeaderText="排名" />
<asp:BoundField DataField="unit_name" HeaderText="单位" />
<asp:TemplateField HeaderText="运动员">
<ItemTemplate>
<a title="<%# Eval("sporters_name")%>" href='play.aspx?number=<%# Eval("number")%>&playact_id=<%# Eval("playact_id") %>&game_id=<%# Eval("game_id")%>&value_k=1'>
<%#strFormat((string) Eval("sporters_name"))%></a>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="get_score" HeaderText="总分" />
</Columns>
<SelectedRowStyle ForeColor="#CC0000" />
</asp:GridView>
后台代码
this.GridView1.DataSource = DBHelper.GetDataSet(sql1).Tables[0]; ;
this.GridView1.DataBind();
for (int i = 0; i <= GridView1.Rows.Count - 1; i++) //循环查找开始
{
string score = GridView1.Rows[i].Cells[0].Text.ToString();
if (score == "-1")
{
GridView1.Rows[i].Cells[0].Text = "弃权";
}
}
怎么根据number是否为-1,-1的时候不用a标签,就是不要用超链接。
怎么没有人帮忙呀???、
我记得好像是在OnRowDataBind事件里处理的。不做这个太久了记不清了。