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

[Solved] FormTemplate Questions

3 Answers 182 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 04 Feb 2008, 09:38 PM
I have a formtemplate, inside i have a listbox with id of PriorityType and a textbox with ID = title

so I thought I could populate these when you press the edit button with the itemdatabound event, but this doesn't seem to do anything.  Do I need to somehow hook up the databinding elsewhere besides here?  Does ajax through a wrinkle with the databinding?  I'm at a loss as to why nothing shows up when I hit edit.  Are there examples on custom forms that don't use usercontrols?

protected

void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)

{

if (e.Item is GridEditFormItem && e.Item.IsInEditMode)

{

GridEditFormItem editFormItem = (GridEditFormItem)e.Item;

TextBox tb = editFormItem.FindControl("Title") as TextBox;

tb.Text =

"HELLO";

ListBox lb = editFormItem.FindControl("PriorityType") as ListBox;

lb.Items.Add(

"HELLO");

}

}

3 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 04 Feb 2008, 09:59 PM
Never mind figured out my problem

in the <telerik:RadGrid tag you need to add 

OnItemDataBound="RadGrid1_ItemDataBound"

0
John
Top achievements
Rank 1
answered on 05 Feb 2008, 02:36 AM
I'm now having problems with the updates, from the examples it is not clear where to put what handlers and how.

How do I get a button in a template to fire using the GridCommandEventArgs so I can get references to the row.

I've seen lots of examples with user controls and in memory db calls and such, but its not clear how to fire this even.

Do i use itemcommands or updatecommands or what?  Everything I've tried hasn't worked.


in the grid tag I have 

OnItemCommand

="RadGrid1_ItemCommand"

in the button tag I have

CommandName="SaveEdit"

and in the code behind I have

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

{

if (e.CommandName == "SaveEdit")

{

GridEditableItem editedItem = e.Item as GridEditableItem;

Int32 id = Convert.ToInt32(editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["ID"]);

ToDo todo = new ToDo(id);

todo.DraftStatusID = 1;

todo.Title =

"TESTING THIS " + id.ToString();

todo.Save();

}

}

and this doesn't seem to ever get triggered.

What am I missing



0
John
Top achievements
Rank 1
answered on 05 Feb 2008, 04:46 AM
Finally got it working with the update command, turns out I had enable viewstate = false so it broke.
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Share this question
or