This is a migrated thread and some comments may be shown as answers.

How do I invoke the edit form on the server side?

2 Answers 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brandon Slezak
Top achievements
Rank 2
Brandon Slezak asked on 14 Aug 2009, 01:04 AM
Ok this may sound really easy but I'm having a hard time figuring it out, basically I have a Grid with an ID and text column, simple add/edit/delete functionality is what I'm looking for.  Because of company standards I cannot use an Object or SQL data source, I'm using MVP and need to bubble the events.

I've got the item_command event firing fine but I'm looking for a way to invoke Telerik's "Automatic" edit form on the server side, does anyone have any ideas? 

As a side note, when I do setup a datasource, automatic operations are fine, I'm just looking for a way to invoke automatic operations without a data source.

I'll post in some aspx and code behind so you can see sort of what I'm trying to do:


<

 

telerik:RadGrid runat="server" ID="radViews" AutoGenerateDeleteColumn="True"

 

 

AutoGenerateEditColumn="True" GridLines="None" AllowAutomaticUpdates="true"

 

 

Skin="Office2007" OnItemCommand="radViews_ItemCommand" >

 

  <

 

HeaderContextMenu EnableTheming="True">

 

<

 

CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

 

</

 

HeaderContextMenu>

 

<

 

MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top">

 

<

 

RowIndicatorColumn>

 

<

 

HeaderStyle Width="20px"></HeaderStyle>

 

</

 

RowIndicatorColumn>

 

<

 

ExpandCollapseColumn>

 

<

 

HeaderStyle Width="20px"></HeaderStyle>

 

</

 

ExpandCollapseColumn>

 

 

<Columns>

 

 

<telerik:GridBoundColumn DataField="ID" DataType="System.Int32" HeaderText="ID"

 

 

SortExpression="ID" UniqueName="ID">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="Text" HeaderText="Text"

 

 

SortExpression="Text" UniqueName="Text">

 

 

</telerik:GridBoundColumn>

 

 

</Columns>

 

</

 

MasterTableView>

 

<

 

FilterMenu EnableTheming="True">

 

<

 

CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

 

</

 

FilterMenu>

 

 

</telerik:RadGrid>

 

protected

 

void radViews_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)

 

{

 

if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked

 

 

 

 

{

    e.Canceled =

true;

 

 

    //Prepare an IDictionary with the predefined values

 

 

 

 

    System.Collections.Specialized.

ListDictionary newValues = new System.Collections.Specialized.ListDictionary();

 

    newValues[

"Tag"] = user.UserName;

 

 

    
    //Insert the item and rebind

 

 

 

 

    e.Item.OwnerTableView.InsertItem(newValues);

}

 

// Pass to MVP

 

 

 

 

 

if (e.CommandName == RadGrid.DeleteCommandName)

 

    {

 

        this.OnDeleteView(this, e);

 

    }

 

if (e.CommandName == RadGrid.EditCommandName)

 

    {

 

        "Go Go Gadget editable Grid!!!!"    

 

 

 

 

    }

 

}

 


2 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 14 Aug 2009, 06:41 AM
Hi Brandon Slezak,

Automatic operations with the RadGrid control are not possible unless you are binding the grid to a data source object. It is namely the commands of the data source object that are automatically invoked by the grid and hence the name automatic operations.

I hope this information helps.

Best Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Brandon Slezak
Top achievements
Rank 2
answered on 14 Aug 2009, 05:05 PM
Thank you very much for the reply, it turns out that the automatic form only works if you add the "need data source" event to it and wire it up, I kept getting pre_render exceptions.

Anyway, thanks for the help I just thought I'd post what I found it in case someone else is searching for manual data binding with insert/update/delete and automatic operations.

-Brandon
Tags
Grid
Asked by
Brandon Slezak
Top achievements
Rank 2
Answers by
Tsvetoslav
Telerik team
Brandon Slezak
Top achievements
Rank 2
Share this question
or