Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Webdatagrid ItemTemplate error

hi , 

iam adding an itemtemplate in the grid the contain the edit and delete buttons with 

TemplateDataField field1 = new TemplateDataField();
field1.Key = "TemplateColumn1";
field1.Header.Text = "Edition ";
//get reference to the template column
TemplateDataField templateColumn1 = (TemplateDataField)this.WebDataGrid1.Columns["TemplateColumn1"];
templateColumn1.ItemTemplate = new CustomItemTemplate();


private class CustomItemTemplate : ITemplate
#region ITemplate Members

public void InstantiateIn(Control container)

Button edit = new Button();
edit.CssClass = "Button";
edit.Text = "Modifier";
edit.OnClientClick = "return editRow()";

Button delete = new Button();
delete.CssClass = "Button";
delete.Text = "Supprimer";
delete.OnClientClick = "return deleteRow()";



but i get in this.WebDataGrid1.Columns.Add(field1); line when i clique any button

Key:TemplateColumn1 must be unique. The field objects in the grid must have non-empty unique keys assigned to the Key property.

to put this another way how to do this in codebehind


                        <ig:TemplateDataField  Key="TemplateColumn0">
                            <Header Text="Edition HTML"></Header>

                                <asp:Button ID="Buttonedit" runat="server" Text="Edit HTML" onclientclick="eturn editRow();" />

                                <asp:Button ID="Buttondelete" runat="server" Text="Delete HTML" onclientclick="return deleteRow();" />


Top Replies