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

[Solved] Show EditForm for clicked row ?

1 Answer 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Madhu Palakurthi
Top achievements
Rank 1
Madhu Palakurthi asked on 07 Mar 2013, 02:38 AM
Hi,

I have a grid has <EditFormSettings EditFormType="Template" .
I have a linkbutton draft column in the grid and showing edit form once click on draft link button.

But its binding last row values always .I have written the code in the itemdatabound event.

for example I have 2 records in the grid and If i click on 1st record then it's always showing 2nd row in the edit form popup that mean my code calling twice at this scenario.

itemdatabound calling for every record and showing last record values in the popup.

this is my code :

If System.Web.HttpContext.Current.Session("state") IsNot Nothing Then
            If System.Web.HttpContext.Current.Session("state").ToString = "SaveAsDraft" Then
                If TypeOf e.Item Is GridDataItem Then
                    Dim item As GridDataItem = TryCast(e.Item, GridDataItem)
                    ViewState("EmailIdValue") = item("id").Text
                End If
                If TypeOf e.Item Is GridEditFormItem And e.Item.IsInEditMode Then
                    If e.Item.OwnerTableView.IsItemInserted Then
                        Dim record As New DataTable
                        If ViewState("EmailIdValue") <> "" Then
                            record = GetDataTable("select * from t_EmailFiling where id='" & ViewState("EmailIdValue") & "'")
                        End If
                        If record.Rows.Count > 0 Then
                            Dim insertItem As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem)
                            CType(insertItem.FindControl("Recipient"), RadTextBox).Text = record.Rows(0)("Recipient").ToString()
                            CType(insertItem.FindControl("RecipientCC"), RadTextBox).Text = record.Rows(0)("RecipientCC").ToString()
                            CType(insertItem.FindControl("RecipientBCC"), RadTextBox).Text = record.Rows(0)("RecipientBCC").ToString()
                            CType(insertItem.FindControl("Subject"), RadTextBox).Text = record.Rows(0)("Subject").ToString()
                            CType(insertItem.FindControl("Message"), RadEditor).Content = record.Rows(0)("Message").ToString()
                        End If
                    End If
                End If
            End If
            End If
 

I would like to show in the editform that exact row what i have clicked in the grid. Please help me on this..

Thanks in advance ..

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Mar 2013, 04:05 AM
Hi,

One suggestion is that you can handle the click event of the button to show the row in edit mode.
VB:
Protected Sub LinkButton1_Click(sender As Object, e As EventArgs)
    Dim link As LinkButton = DirectCast(sender, LinkButton)
    Dim item As GridDataItem = DirectCast(link.NamingContainer, GridDataItem)
    item.Edit = True
    RadGrid1.Rebind()
End Sub

Thanks,
Shinu
Tags
Grid
Asked by
Madhu Palakurthi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or