Hi,
In a radgrid with automatic edit/insert/delete, is there a way to either automatically enter default values (like the current date and time) into a text box when the user clicks edit or add new, or a way to get and modify the entry boxes' content or the compiled SQL statement before it is executed after the user clicks update? I want to use the current date and time for date entries in some SQL databases. I guess I could probably just make the date fields read only and call a separate SQL edit command inserting the dates, but would rather not.
Thanks,
Chris
In a radgrid with automatic edit/insert/delete, is there a way to either automatically enter default values (like the current date and time) into a text box when the user clicks edit or add new, or a way to get and modify the entry boxes' content or the compiled SQL statement before it is executed after the user clicks update? I want to use the current date and time for date entries in some SQL databases. I guess I could probably just make the date fields read only and call a separate SQL edit command inserting the dates, but would rather not.
Thanks,
Chris
6 Answers, 1 is accepted
0
0

Chris
Top achievements
Rank 1
answered on 02 Jun 2010, 03:10 PM
That looks like it will work great, thanks. But I'm using vb and am having trouble with "ColumnUniqueName" and getting the control and casting it to a textbox. Any help on how to change that line to vb?
Thanks again,
Chris
Thanks again,
Chris
0

Princy
Top achievements
Rank 2
answered on 03 Jun 2010, 11:40 AM
Hello Chris,
You can easily convert the C# code to VB equivalent and vice versa, using the following online .net code converter.
Code Converter
And here is the code in VB:
Thanks,
Princy.
You can easily convert the C# code to VB equivalent and vice versa, using the following online .net code converter.
Code Converter
And here is the code in VB:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) |
If e.Item.OwnerTableView.IsItemInserted AndAlso TypeOf e.Item Is GridEditFormInsertItem Then |
Dim item As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem) |
Dim textBox As TextBox = DirectCast(item("ColumnUniqueName").Controls(0), TextBox) |
textBox.Text = "My Text" |
End If |
End Sub |
Thanks,
Princy.
0

Chris
Top achievements
Rank 1
answered on 03 Jun 2010, 12:53 PM
Hi Princy,
I was wondering if there was a converter like that, but never bothered to look for one, so thank you.
This code works for when adding a new item, but I would also like to do this or something similar for when the user clicks to edit a row. I've tried a little bit myself, but my understanding of all this isn't quite good enough yet. Any help with this would be greatly appreciated.
Also, how would I change this to work for inPlace inserting/editing?
Thanks,
Chris
P.S.
The Code Converter link doesn't work.
I was wondering if there was a converter like that, but never bothered to look for one, so thank you.
This code works for when adding a new item, but I would also like to do this or something similar for when the user clicks to edit a row. I've tried a little bit myself, but my understanding of all this isn't quite good enough yet. Any help with this would be greatly appreciated.
Also, how would I change this to work for inPlace inserting/editing?
Thanks,
Chris
P.S.
The Code Converter link doesn't work.
0
Accepted

Princy
Top achievements
Rank 2
answered on 04 Jun 2010, 01:07 PM
Hello Chris,
Check out the following code snippet to access the control in InPlace edit/insert.
VB.Net:
And here is the converter link:
http://converter.telerik.com
Thanks,
Princy.
Check out the following code snippet to access the control in InPlace edit/insert.
VB.Net:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) |
If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then |
If e.Item.OwnerTableView.IsItemInserted AndAlso TypeOf e.Item Is GridDataInsertItem Then |
Dim item1 As GridDataInsertItem = DirectCast(e.Item, GridDataInsertItem) |
Dim textBox As TextBox = DirectCast(item1("ColumnUniqueName").Controls(0), TextBox) |
textBox.Text = "My Text insert" |
Else |
Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem) |
Dim textBox As TextBox = DirectCast(item("ColumnUniqueName").Controls(0), TextBox) |
textBox.Text = "My Text edit" |
End If |
End If |
End Sub |
And here is the converter link:
http://converter.telerik.com
Thanks,
Princy.
0

Chris
Top achievements
Rank 1
answered on 04 Jun 2010, 01:38 PM
Thanks, that's great!