Hi,
I create dynamic Link Button in my grid depending on DateFields.
I have had a TemplateColumn like this
In my code behind i do that
My Grid can be expan or collapse and when I Expand or collapse i Lost my control ...
Ditto When I click on LinkButton i lost control too and i can't start GridCommand and lbAction Event click
I have try to make the same code on ItemCreated but the result is the same.
How I can keep my control ??
Thank you.
PS : Sorry for my English
I create dynamic Link Button in my grid depending on DateFields.
I have had a TemplateColumn like this
<
telerik:GridTemplateColumn
HeaderText
=
"Action"
UniqueName
=
"tplColAction"
>
<
ItemTemplate
>
<
asp:Panel
ID
=
"pnlActionStatut"
runat
=
"server"
HorizontalAlign
=
"left"
>
</
asp:Panel
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
In my code behind i do that
protected void rdGridOpportunite_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item.ItemType != GridItemType.Item && e.Item.ItemType != GridItemType.AlternatingItem) return;
//Get Object Entity
OpportuniteEntity opp = e.Item.DataItem as OpportuniteEntity;
if (opp == null) return;
//Get Panel
Control pnl = e.Item.FindControl("pnlActionStatut");
if (!(pnl is Panel)) return;
//Get All statut associate of this statut
List<
TypeStatutOpportuniteEntity
> statuts = TypeManager.GetStatutAssocieOfStatut(opp.TypeStatut.IDType, Profile.InstanceID).ToList();
if (statuts.Count == 0) return;
LinkButton lbAction;
//Create LinkButton for each Statut
statuts.ForEach(s =>
{
lbAction = new LinkButton();
lbAction.Text = "--> " + s.Libelle;
lbAction.Click += new EventHandler(lbAction_Click);
lbAction.CommandArgument = string.Format("{0};{1}", opp.ID, s.IDType);
lbAction.ID = string.Format("lnkBtn{0}{1}", opp.ID, s.IDType);
pnl.Controls.Add(lbAction);
pnl.Controls.Add(new Label() { Text = "<
br
/>" });
}
);
}
My Grid can be expan or collapse and when I Expand or collapse i Lost my control ...
Ditto When I click on LinkButton i lost control too and i can't start GridCommand and lbAction Event click
I have try to make the same code on ItemCreated but the result is the same.
How I can keep my control ??
Thank you.
PS : Sorry for my English