这是我的代码中的问题部分。
DataView view = ds.Tables[0].DefaultView;
view.Sort = "user_id ASC, ip_address DESC;
BalaiStatus.DataSource = view;
BalaiStatus.DataBind();
>>BalaiStatus.DataBind().Sort = "ip_address ASC";<<
BalaiStatus 将处理函数 BalaiStatus_RowDataBound。这段代码是为了消除gridview中的同一行。代码是: -
string lastRow = "";
protected void BalaiStatus_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
var thisRow = e.Row;
if (thisRow.Cells[0].Text == lastRow)
{
e.Row.Visible = false;
}
}
else {
DataRowView view = (DataRowView)e.Row.DataItem;
string login = Convert.ToString(view["ip_address"]);
if (login == "")
{
e.Row.Cells[2].BackColor = Color.Red;
}
else
{
Global.rowCount = Global.rowCount + 1;
e.Row.Cells[2].ForeColor = Color.White;
e.Row.Cells[2].BackColor = Color.Green;
}
Global.allCount = Global.allCount + 1;
}
lastRow = thisRow.Cells[0].Text;
}
所以,我需要的是,在消除相同的行之后,我想再次对 gridview 中的更新数据进行排序。请看>>代码<<..
任何人都请帮我解决这个问题。感谢您的意见或建议。谢谢西蒂。