本文介绍了如何使用按钮点击更改asp网格中的gridview行颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的数据绑定方法
This is My databind Method
DateTime fldate = DateTime.Parse(txtflightDate.Text);
String refcode = DropdownRefcode.SelectedItem.Text.ToString().Trim();
dt = ML.getMainfestAll(fldate, refcode);
if (dt != null && dt.Rows.Count > 0)
{
GridViewml.DataSource = dt;//
GridViewml.DataBind();
}
我需要添加这是方法数据绑定时间怎么做。任何人都可以帮助我。
I need to add This is Method databind time how do it.any one can help me.
DataTable NEW = new DataTable();
for (int i = 0; i < GridViewml.Rows.Count; i++)//
{
String hawb = GridViewml.Rows[i].Cells[1].Text;//1
NEW = ML.getsatlisting(hawb);
if (NEW != null && NEW.Rows.Count > 0)
{
White;//
}
else
{
SkyBlue;
}
}
推荐答案
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int rowIndex = Convert.ToInt32(e.CommandArgument);
foreach (GridViewRow row in GridView1.Rows)
{
row.BackColor = row.RowIndex.Equals(rowIndex) ?
System.Drawing.Color.Red :
System.Drawing.Color.White;
}
}
if(yourcondition)
{
GridView1.RowStyle.BackColor = System.Drawing.Color.White;
}
else
{
GridView1.RowStyle.BackColor = System.Drawing.Color.Aqua;
}
这篇关于如何使用按钮点击更改asp网格中的gridview行颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!