我目前正在突出显示gridview中的匹配行,但要查看它我必须向下滚动。我想设置滚动条的位置,以便匹配记录始终可见。
protected void MatchGrid_OnRowDataBound(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//bool ismatch = (bool)DataBinder.Eval(e.Row.Cells, e.Row.Cells[2].Text ="Main");
//if (ismatch) e.Row.BackColor = Color.FromName("#FAF7DA");
// Highlights the selected row and makes the text bold
if (e.Row.Cells[2].Text.ToLower() == txtHouseNumber.Text.ToLower() && e.Row.Cells[3].Text.ToLower() == txtStreetName.Text.ToLower())
{
e.Row.Cells[1].Text = "<b>" + e.Row.Cells[1].Text + "</b>";
e.Row.Cells[2].Text = "<b>" + e.Row.Cells[2].Text + "</b>";
e.Row.Cells[3].Text = "<b>" + e.Row.Cells[3].Text + "</b>";
e.Row.BackColor = Color.FromName("#FAF7DA");
//This is what I was trying to use
GV_NEMOAddresses.SelectedIndex = e.Row.RowIndex;
}
}
}
如果可能,我更愿意在没有Javascript的情况下这样做。