Change Buttonfield image dynamically
-
I have a gridview with a buttonfield, and I would like to change the image URL of the field based on a condition of one of the fields. How do I reference the buttonfield?
-
I have a gridview with a buttonfield, and I would like to change the image URL of the field based on a condition of one of the fields. How do I reference the buttonfield?
Please, start asking ASP.NET questions in the ASP.NET forum. There are so many grid views that have different behaviours depending on what the underlying technology, that it we could quite easily give you the wrong answer. Also, could you please change your user name? If you don't, you will end up being spammed. Now, as to your question (and please let this be the last ASP.NET one that you ask in this forum), how you change your button field really depends on how you want to trigger the field change. If it's just based on when you are binding the data to the GridView, there is a
RowDataBound
event that you can hook into when each row is bound to data. What you would do in this method is find the field you want (here's a crude method):private void CustomersGridView_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Button btnField = (Button)e.Row.FindControl("btnField");
}
}*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier