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

[Solved] Problem using form (BeginForm) in grid column

1 Answer 21 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andrew
Top achievements
Rank 1
Andrew asked on 27 Jun 2011, 10:07 AM
I had a page that used a standard HTML table with a form for deleting a row (user) in one of the columns (a form in each row).

However, when I converted this page to use the Telerik MVC grid, the form doesn't seem to be rendering correctly. Is this because the grid renders it's own form and so my forms are now nested?

If so, how can I get around this. I need a button that will call an MVC action to delete a user (and display a javascript alert to confirm that this operation should really happen).

My current (non-working) code snippet is below:

columns.Template(
                @<text>
                    @if (!item.Username.Equals("administrator", StringComparison.CurrentCultureIgnoreCase)) 
                    {
                        using (Html.BeginForm("Delete", null)) 
                        {
                            @Html.Hidden("id", item.Id)


                            <button type="submit" onclick="javascript:return confirm('You are about to delete a user!')">Delete</button>
                        }
                    }
                    else 
                    {
                        <text>&nbsp;</text>
                    }             
                </text>)

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 27 Jun 2011, 10:19 AM
Hi Andrew,

Forms are rendered in the output of the page instantly. This requires you to use the Render() method of the grid:

@ {
  Html.Telerik().Grid()
           .Render();
}

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or