Using different WebUserControls as custom edit form

Thread is closed for posting
6 posts, 0 answers
  1. Telerik Admin
    Telerik Admin avatar
    1679 posts
    Member since:
    Oct 2004

    Posted 27 Apr 2006 Link to this post

     

    Requirements

    RadGrid for ASP .NET version

    3.1.1 and later

    .NET version

    1.x

    Visual Studio version

    2002 and later

    Programming language

    VB.NET

    Browser support

    all supported by RadGrid for ASP .NET


     
    Actually you have one and the same user control but with distinctive set of controls inside it. This project presents how to display file upload edit form when clicking the Upload file link button in an arbitrary grid row:
    1. check whether e.CommandName is the name you specified for your GridButtonColumn
    2. if so, switch the item in edit mode and rebind the grid (saving indicator in the Session for changing the edit form state)
    3. wire the ItemCreated event to verify that the item is in edit mode and the Session flag is raised
    4. clear the Controls collection of the EditFormCell for the GridEditFormItem
    5. add HtmlInputFile control and upload button to the Controls collection of the EditFormCell for the GridEditFormItem

    Note that the demo does not hold real update/file upload. If this is needed, you should include this functionality by writing custom code according to your requirements.

     

  2. Congero
    Congero avatar
    20 posts
    Member since:
    Sep 2012

    Posted 07 May 2006 Link to this post

    Do you have this sample in vs2005 and .net 2.0?
  3. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 08 May 2006 Link to this post


    Hello Reggie,

    Actually the core of this example is in these two methods:

    Private Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles RadGrid1.ItemCommand

    If (e.CommandName = RadGrid.EditCommandName) Then
        Session("changeEditForm") = Nothing
    End If

    If (e.CommandName = "UploadFile" AndAlso TypeOf e.Item Is GridDataItem) Then
        e.Item.Edit = True
        Session("changeEditForm") = True
        RadGrid1.Rebind()
    End If

    If (e.CommandName = "Close") Then
        RadGrid1.EditIndexes.Clear()
        RadGrid1.Rebind()
    End If

    End Sub

     

    Private Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.WebControls.GridItemEventArgs) Handles RadGrid1.ItemCreated

    If (TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode) Then
        If (Not Session("changeEditForm") Is Nothing) Then

            Dim formItem As GridEditFormItem = CType(e.Item, GridEditFormItem)
            formItem.EditFormCell.Controls.Clear()
            formItem.EditFormCell.Controls.Add(
    New System.Web.UI.HtmlControls.HtmlInputFile)    
            formItem.EditFormCell.Controls.Add(
    New LiteralControl("<br/>"))

            Dim
    uploadButton As Button = New Button

            uploadButton.Text = "Upload file"

            uploadButton.CommandName = "Upload"

            formItem.EditFormCell.Controls.Add(uploadButton)

            Dim closeButton As Button = New Button

            closeButton.Text = "Close"

            closeButton.CommandName = "Close"

            formItem.EditFormCell.Controls.Add(closeButton)

        End If

    End If

    End Sub

    and you can easily use them in VS.NET 2005.

    Regards,
    Stephen,
    the telerik team
  4. Congero
    Congero avatar
    20 posts
    Member since:
    Sep 2012

    Posted 08 May 2006 Link to this post

    Hi Vlad
    Thanks for the Heads Up!  What I am trying to do is use a grid as a data entry form that will allow a user to update 1 record. (No insert or delete required)  Do you have any other articles that will help me to understand how to do this.  Thanks

  5. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 08 May 2006 Link to this post


    Hello Reggie,

    We believe that the following topics from the grid online documentation can help you understand the specifics of the edit/update mechanism of r.a.d.grid:

    http://www.telerik.com/help/radgrid/3.2.Net2/ (section Insert/Update/Delete)

    Best regards,
    Stephen
    the telerik team
  6. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 10 May 2006 Link to this post


    Hi folks,

    Here is the C# version of this example (under .NET 1.x framework) which has been kindly provided by Mostafa Anoosheh. Feel free to use that version in case this is the programming language you choose.

    And happy coding :)
     
    Best,
    Stephen
    the telerik team
Back to Top