ورود

View Full Version : data grid special row



Silverboy
سه شنبه 11 بهمن 1384, 19:54 عصر
سلام اگه توی datagrid یا gridview بخواهی که ردیف هایی که مثلا فیلد x شون برابر با 100 است دکمه delete شون فعال باشه باید چه کار کنی؟
تا بتونی این شرط رو برقرار کنی ؟

nokhod
چهارشنبه 12 بهمن 1384, 19:13 عصر
سلام.


for (int i=0 ; i<ds.Tables["Table1"].Rows.Count ; i++)
{
Label lbl = (Label)DataGrid1.Items[i].FindControl("Your label name in datagrid");
Button btn = (Button)DataGrid1.Items[i].FindControl("Your button name in datagrid");
if (lbl.Text = "100")
{
btn.Visible = true;
}
else
{
btn.Visible = false;
}
}

موفق باشید.

Silverboy
دوشنبه 17 بهمن 1384, 18:00 عصر
عزیز دل برادر این که شد دوباره کای من دنبال یه مکانیسم خو دکارم

AspNet
دوشنبه 17 بهمن 1384, 18:15 عصر
void productsGridView_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// determine the value of the UnitsInStock field
int unitsInStock =
Convert.ToInt32(DataBinder.Eval(e.Row.DataItem,
"UnitsInStock"));
if (unitsInStock == 0)
// color the background of the row yellow
e.Row.BackColor = Color.Yellow;
}
}


البته من فقط شرط رو نوشتم که مربوط به رویداد DataBound هست .