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

Editing Child Templates

8 Answers 142 Views
GridView
This is a migrated thread and some comments may be shown as answers.
KawaUser
Top achievements
Rank 2
KawaUser asked on 28 Mar 2011, 01:36 PM
How do you edit templates in a hierarchy view?

8 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 28 Mar 2011, 01:48 PM
Hello,

Please could you be more specific about what you would like to achieve. For reference, the help topic on programatically binding to hierarchy data can be found here.

Look forward to hearing back from you
Richard
0
KawaUser
Top achievements
Rank 2
answered on 28 Mar 2011, 01:52 PM
How do you type in the column and commit the information to the DB?

Thank you,

Chuck
0
Richard Slade
Top achievements
Rank 2
answered on 28 Mar 2011, 01:55 PM
Hello,

As long as the column allows editing, then you can click to edit a cell just as you would in the Master Template.
Commiting the data to the database will depend on how you are dealing with your databadse. E.g. Via an ORM, table adapters etc...

Regards,
Richard
0
KawaUser
Top achievements
Rank 2
answered on 28 Mar 2011, 05:50 PM
I commit it to the database on the cell end edit event using SQL update.

Thanks,
Chuck
0
Accepted
Martin Vasilev
Telerik team
answered on 31 Mar 2011, 05:01 PM
Hello KawaUser,

Thank you for writing.

I am still not sure that I understand your requirement. In case you want to update sql database, please find detailed description how to do that in the following msdn article.

If this does not help, please provide us with more details of your exact scenario and your goals. 

Best wishes, Martin Vasilev
the Telerik team
0
KawaUser
Top achievements
Rank 2
answered on 05 May 2011, 06:00 PM
I want to do something similar to this, but for the template.

How do I call the template column?

If DataGridReject.CurrentColumn.HeaderText = "ADMIN FEE" Then
 
                        Dim header = DataGridReject.CurrentColumn.Name
 
                        If e.Value Is Nothing Then
 
                        ElseIf e.Value.ToString = "1" Then
 
                            Dim updateString As String = "UPDATE REJECT_REPORT SET " + header + " = '1' WHERE REJECT_ID = '" + rejectID + "'"
 
                            conn.Open()
 
                            Dim comm = New SqlCommand(updateString, conn)
                            comm.ExecuteNonQuery()
 
                            conn.Close()
 
                        ElseIf e.Value.ToString = "0" Then
 
                            Dim boxValue As Integer = 0
 
                            Dim updateString As String = "UPDATE REJECT_REPORT SET " + header + " = '0' WHERE REJECT_ID = '" + rejectID + "'"
 
                            conn.Open()
 
                            Dim comm = New SqlCommand(updateString, conn)
                            comm.ExecuteNonQuery()
 
                            conn.Close()
 
                        End If
 
                    End If

ANSWER:

If DataGridReject.Templates(0).CurrentColumn.HeaderText = "MATERIAL_NO" Then
 
               Dim MATERIAL As String = ""
 
           End If
0
Martin Vasilev
Telerik team
answered on 10 May 2011, 03:22 PM
Hello KawaUser,

Thank you for sharing your code with us.

As far as I understand you have managed to find a solution for your requirement. Feel free to write me back if you have any additional questions.

Greetings,
Martin Vasilev
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
0
KawaUser
Top achievements
Rank 2
answered on 10 May 2011, 04:04 PM
Yes, I have figured this problem out. I wanted to programatically edit the cells. This is the code inside the datagrid_cellendedit sub routine.

If DataGridReject.Templates(0).CurrentColumn.HeaderText = "MATERIAL_NO" Then
 
           Dim rejectID = DataGridReject.CurrentRow.Cells(2).Value.ToString
           Dim revision = DataGridReject.CurrentRow.Cells(3).Value.ToString
 
           Dim materialUpdateStr As String = "exec spRR_UPDATEPARTSLISTMATERIAL '" + rejectID + "', '" + revision + "', '" + e.Value.ToString + "'"
 
           conn.Open()
 
           Dim comm = New SqlCommand(materialUpdateStr, conn)
           comm.ExecuteNonQuery()
 
           conn.Close()
 
       End If
Tags
GridView
Asked by
KawaUser
Top achievements
Rank 2
Answers by
Richard Slade
Top achievements
Rank 2
KawaUser
Top achievements
Rank 2
Martin Vasilev
Telerik team
Share this question
or