【下面是我的代码】
protected void grv_CustomerIncomeTbl_RowDataBound(object sender, GridViewRowEventArgs e)
{
string grvtittle = "";//*号
for (int i = 0; i < this.grv_CustomerIncomeTbl.Rows.Count ; i++)
{
grvtittle = grv_CustomerIncomeTbl.Rows[i].Cells[12].Text;
if (grvtittle == "1")
{
grv_CustomerIncomeTbl.Rows[i].Cells[12].Text = "*";
}
else
{
grv_CustomerIncomeTbl.Rows[i].Cells[12].Text = "";
}
}
} 我想要的事 当Cells[12].Text值等于1时 就显示*号 但是现在有个问题 当数据多时 就会把它给覆盖了
也就是 本来第一行时="1" 就显示* 当循环到地二行时 第二行的数据="0" 就不显示* 但是现在回把第一行的数据也付成“”了 请大家帮帮忙 解决下·!
protected void grv_CustomerIncomeTbl_RowDataBound(object sender, GridViewRowEventArgs e)
{
string grvtittle = "";//*号
for (int i = 0; i < this.grv_CustomerIncomeTbl.Rows.Count ; i++)
{
grvtittle = grv_CustomerIncomeTbl.Rows[i].Cells[12].Text;
if (grvtittle == "1")
{
grv_CustomerIncomeTbl.Rows[i].Cells[12].Text = "*";
}
else
{
grv_CustomerIncomeTbl.Rows[i].Cells[12].Text = "";
}
}
} 我想要的事 当Cells[12].Text值等于1时 就显示*号 但是现在有个问题 当数据多时 就会把它给覆盖了
也就是 本来第一行时="1" 就显示* 当循环到地二行时 第二行的数据="0" 就不显示* 但是现在回把第一行的数据也付成“”了 请大家帮帮忙 解决下·!
加上类别判断 if (e.Row.RowType == DataControlRowType.DataRow)
{ }
protected void grv_CustomerIncomeTbl_RowDataBound(object sender, GridViewRowEventArgs e)
{
string grvtittle = "";//*号
grvtittle = e.Row.Cells[12].Text;
if (grvtittle == "1")
{
e.Rows.Cells[12].Text = "*";
}
else
{
e.Row.Cells[12].Text = "";
}
}
protected void grv_CustomerIncomeTbl_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
e.Row.Cells[12].Text = e.Row.Cells[12].Text == "1" ? "*" : "";
}
GridViewRow row = e.Row;
if (RowType != DataControlRowType.Header && RowType != DataControlRowType.Footer)
{
grvtittle = grv_CustomerIncomeTbl.Rows[row.RowIndex].Cells[12].Text;
if (grvtittle == "1")
{
grv_CustomerIncomeTbl.Rows[row.RowIndex].Cells[12].Text = "*";
}
else
{
grv_CustomerIncomeTbl.Rows[row.RowIndex].Cells[12].Text = "";
}
}
if (e.Row.RowType == DataControlRowType.DataRow)
{ }
我改成模板列 就解决了 呵呵 分一样照给! if (e.Row.RowType == DataControlRowType.DataRow)
{
Label text = (Label)e.Row.FindControl("lbl_Czq");
if (text.Text == "1")
{
text.Text = "*";
}
else
{
text.Text = "";
}
}