Archive for the ‘Telerik’ Category

Telerik radGrid -ItemTemplate,EditTemplate

August 22, 2016

Points

  • Browser side: Use normal controls – a lot like asp.net gridview (label, hidden, etc)
  • Server side a little different
  • Must grab control[1]. Control[0] is a literal – I suppose the start of the <td>.

Browser Side:

<telerik:GridTemplateColumn Display=”false” UniqueName=”ReceiptItemID”>

<ItemTemplate>

<asp:HiddenField ID=”hdnReceiptItemID” runat=”server” Value=”<%# Item.ParkedReceiptItemID %>” />

</ItemTemplate>

<EditItemTemplate>

<asp:HiddenField ID=”hdnReceiptItemID” runat=”server” Value=”<%# Item.ParkedReceiptItemID %>” />

</EditItemTemplate>

</telerik:GridTemplateColumn>

 

<telerik:GridTemplateColumn HeaderText=”AccountNumber” UniqueName=”AccountNumber” >

<ItemTemplate>

<asp:Label ID=”lblAccountNumber” runat=”server” Text='<%# Item.AccountNumber %>’ ></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<uc1:ctlCombo ID=”cboAccountNumber” ClientIDMode=”Static” runat=”server” Text='<%# Item.AccountNumber %>’ />

</EditItemTemplate>

</telerik:GridTemplateColumn>

 

Server side:

//Get all the new values of the edited row.

GridEditableItem rgEditedItem = (GridEditableItem) e.Item;

 

 

// Label lbl = (Label) rgEditedItem[“ReceiptItemID”].Controls[1];

HiddenField hdn = (HiddenField)rgEditedItem[“ReceiptItemID”].Controls[1];

 

// int ReceiptItemID = lbl.Text.toInt(0);

int ReceiptItemID = hdn.Value.toInt(0);

 

// update account number if it changed

ctlCombo cbo = (ctlCombo)rgEditedItem[“AccountNumber”].Controls[1];

if (cbo.PreviousValue != cbo.Text && ReceiptItemID > 0)

{

int iret = _parkedReceiptItem.update_Account(ReceiptItemID, cbo.Text, globals.StaffID, ref iError, ref strErrorShort, ref strErrorLong);

if (iError < 0) globals.lblError = globals.ErrorMessage(strErrorShort, strErrorLong, “Problem with account”, “rgItems_UpdateCommand.account”, -2223);

}

 

Advertisements

Telerik radgrid inline editing command not firing

August 19, 2016

oops – my problem was old school .net

in my OnLoad, I was reloading and rebinding the radGrid

that blew away all events

shades of .Net 2003!