"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:2E**********************************@microsof t.com...
hey all,
you know in the gridView quick task menu how you have the option of taking
a
bound column and converting it into a TemplateColumn. Alright, once i do
that
i goto edit the template column and then add a label (or any control) to
the
itemTemplate, and then end the editing.
how can i do this dynamically in the code-behind. can someone please show
me
a small example, for instance adding a label to a ItemTemplate
thanks,
rodchar
After converting to a template, go to the template and put in a panel, say
"ID_MyPanel". If there is anything in the template field (item or edit)
then delete it. There may already be a label there for you.
Anyway, at the callback
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
}
you can find your panel with the following code:
Panel thisPanel = (Panel)e.Row.FindControl("ID_MyPanel");
once you found the panel you can add any controls you want, setting style
and attributes programmatically
HtmlImage thisSpectrum = new HtmlImage();
thisSpectrum.Style.Add(HtmlTextWriterStyle.BorderS tyle, "solid");
thisSpectrum.Style.Add(HtmlTextWriterStyle.BorderW idth, "1px");
thisSpectrum.Attributes.Add("title", "click here to see tits");
thisSpectrum.Attributes.Add("onclick", "return
SpectrumImages_onclick('juggs.jpg')");
thisPanel.Controls.Add(thisSpectrum);
The above adds an "html" Image and client side click handler, if you want a
"data" Image and server side just use "Image" instead. There is a code
snippet here where I finally figured out how to have a drop down list in one
column change the image in another. news:12*************@corp.supernews.com
all one server side.