Programmatically change Telerik GridEditCommandColumn EditText per row in RadGrid -
i have radgrid grideditcommandcolumn. i'd have edittext property of each row change based on contents of row. eg, change edittext 'edit' 'edit product' or 'edit bundle' based on contents of row.
i tried using databinding syntax got error saying doesn't support databinding.
is there event can hook change value of edittext programmatically per row?
is want? anyway can find , edit through onitemdatabound... put in uniquename on edit command column.. find control it.
.aspx
<asp:scriptmanager id="sm" runat="server"></asp:scriptmanager> <telerik:radgrid id="radgrid1" runat="server" autogeneratecolumns="false" onitemdatabound="radgrid1_itemdatabound"> <mastertableview> <columns> <telerik:grideditcommandcolumn buttontype="linkbutton" uniquename="grideditcommandcolumn"></telerik:grideditcommandcolumn> <telerik:gridtemplatecolumn> <itemtemplate> <asp:label id="lbl" runat="server" text='<%# eval("a") %>'></asp:label> </itemtemplate> </telerik:gridtemplatecolumn> </columns> </mastertableview> </telerik:radgrid> </asp:scriptmanager>
.cs
protected void page_load(object sender, eventargs e) { if (!ispostback) { datatable dt = new datatable(); dt.columns.add("a"); string[] array = { "product", "goods", "category", "foods" }; // loop & add (int = 0; < array.length; i++) dt.rows.add(array[i]); // bind radgrid1.datasource = dt; radgrid1.databind(); dt.dispose(); } } protected void radgrid1_itemdatabound(object sender, griditemeventargs e) { // check if (e.item griddataitem) { // variable & find control string value = string.empty; griddataitem item = e.item griddataitem; linkbutton lbtnedit = item["grideditcommandcolumn"].controls[0] linkbutton; label lbl = item.findcontrol("lbl") label; // check & set value if (lbl != null) value = lbl.text.trim(); // check if (lbtnedit != null) lbtnedit.text = "edit " + value; } }
Comments
Post a Comment