View Full Version : سوال: جستجو در GridView
sakbari
یک شنبه 02 مرداد 1390, 09:53 صبح
من یه GridView دارم که میخوام یه شرط روی تک تک خطوطش اعمال بشه و هر جا که شرط برقرار بود اون خط رنگش تغییر کنه
چطور میتونم این کار رو انجام بدم،با در نظر گرفتن این نکته که که GridView من Paging داره و برای همین row index رو ندارم :(
Peyman.Gh
یک شنبه 02 مرداد 1390, 13:04 عصر
در رویداد RowDataBound مربوط به GridView شرط مورد نظر را بررسی کنید.
به طور مثال:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
if (GridView1.Rows[i].Cells[1].Text == "Test")
{
GridView1.Rows[i].Style["background-color"] = "Red";
}
}
}
موفق باشید.
B@H@2R
یک شنبه 02 مرداد 1390, 13:23 عصر
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.DataItem!=null)
{
DataRowView DRV = (DataRowView)e.Row.DataItem;
if(DRV["Brand"]==DBNull.Value)
{
e.Row.BackColor = System.Drawing.Color.Red;
e.Row.ForeColor = System.Drawing.Color.White;
}
این باید به کارت بیاد.اگه مشکلی بود بپرس
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.