I am creating a dynamic datagrid. The controls in some of the template
columns will have to be generated based on the data contained in them
(i.e. the data for that respective DataField column). For example, if I
have a column called Available, the possible values for it are Yes or
No. In case it is "Yes" I need a label in that column and in case it is
"No" I need a hyperlink. Pls help.
> have a column called Available, the possible values for it are Yes or
> No. In case it is "Yes" I need a label in that column and in case it is
>
> "No" I need a hyperlink. Pls help.
<ItemTemplate>
<asp:Label ID='lbl' ... />
<asp:LinkButton ID='lbtn' .../>
</ItemTemplate>
dataGrid1.ItemCreated += dataGrid1_ItemCreated;
void dataGrid1_ItemCreated(...)
{
DataGridItem item = e.Item;
Control labelControl = item.FindControl("lbl");
Control lbtnControl = item.FindControl("lbtn");
if(toShowLabel)
{
labelControl.Visible = true;
lbtnControl.Visible = false;
} else
{
labelControl.Visible = false;
lbtnControl.Visible = true;
}
}
HTH

Signature
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.com
http://www.edujinionline.com
http://articles.edujinionline.com/webservices
-------------------