8 Answers, 1 is accepted
0
Hi Rick,
You can use the following approach to achieve this requirement:
Hope this helps.
Regards,
Eyup
Telerik
You can use the following approach to achieve this requirement:
protected
void
RadGrid1_DataBinding(
object
sender, EventArgs e)
{
GridDateTimeColumn col = RadGrid1.MasterTableView.GetColumn(
"OrderDate"
)
as
GridDateTimeColumn;
col.DefaultInsertValue = DateTime.Now.ToShortDateString();
}
Hope this helps.
Regards,
Eyup
Telerik
See What's Next in App Development. Register for TelerikNEXT.
0

Rick
Top achievements
Rank 1
answered on 25 Mar 2015, 03:09 PM
I tried your solution but it did not work.
This is the grid when the page opens
1![]()
This is the grid after I hit the 'Add new record' button.
It is here that I want to display the current date.
This is the grid when the page opens
1
This is the grid after I hit the 'Add new record' button.
0

Rick
Top achievements
Rank 1
answered on 25 Mar 2015, 03:16 PM
With gif of screen prints
0
Hi Rick,
I've created a sample RadGrid web site to demonstrate that the suggested approach works as expected. Can you please run the attached application and let me know about the result on your side?
Regards,
Eyup
Telerik
I've created a sample RadGrid web site to demonstrate that the suggested approach works as expected. Can you please run the attached application and let me know about the result on your side?
Regards,
Eyup
Telerik
See What's Next in App Development. Register for TelerikNEXT.
0

Rick
Top achievements
Rank 1
answered on 30 Mar 2015, 04:54 PM
When I changed my column from a string template column to a datetime column it worked.
Now my problem is that the insert to my table no longer works although my update to the same table does work.
Here are the insert and update statements
InsertCommand= " Insert into tasks (Date_Entered ,TaskType_ID , Originator_ID,Owner_ID ,Complete,Task ,Teststand_ID) values(@Date_Entered ,@Tasktype_ID,@Originator_ID, @Owner_ID,0,@Task,@teststand_ID)"
UpdateCommand=" Update tasks set Date_Entered= @Date_Entered ,TaskType_ID =@TaskType_ID , Originator_ID =@Originator_ID,Owner_ID = @Owner_ID ,Complete = @Complete,Task=@Task where Task_ID =@Task_ID">
Now my problem is that the insert to my table no longer works although my update to the same table does work.
Here are the insert and update statements
InsertCommand= " Insert into tasks (Date_Entered ,TaskType_ID , Originator_ID,Owner_ID ,Complete,Task ,Teststand_ID) values(@Date_Entered ,@Tasktype_ID,@Originator_ID, @Owner_ID,0,@Task,@teststand_ID)"
UpdateCommand=" Update tasks set Date_Entered= @Date_Entered ,TaskType_ID =@TaskType_ID , Originator_ID =@Originator_ID,Owner_ID = @Owner_ID ,Complete = @Complete,Task=@Task where Task_ID =@Task_ID">
0

Rick
Top achievements
Rank 1
answered on 30 Mar 2015, 04:55 PM
Here are my params...
<InsertParameters>
<asp:Parameter Name="Tasktype_ID" Type="Int32" />
<asp:Parameter Name="Date_Entered" Type="Datetime" />
<asp:Parameter Name="Originator_ID" Type="Int32" />
<asp:Parameter Name="Owner_ID" Type="Int32" />
<asp:Parameter Name="Task" Type="String" />
<asp:ControlParameter ControlID="ComboPLCTestStand" DefaultValue="3" Name="teststand_ID" PropertyName="SelectedValue" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="Tasktype_ID" Type="Int32" />
<asp:Parameter Name="Date_Entered" Type="Datetime" />
<asp:Parameter Name="Originator_ID" Type="Int32" />
<asp:Parameter Name="Owner_ID" Type="Int32" />
<asp:Parameter Name="Task" Type="String" />
<asp:Parameter Name="Task_ID" Type="Int32"/>
<asp:Parameter Name="Complete" type="Boolean"/>
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Tasktype_ID" Type="Int32" />
<asp:Parameter Name="Date_Entered" Type="Datetime" />
<asp:Parameter Name="Originator_ID" Type="Int32" />
<asp:Parameter Name="Owner_ID" Type="Int32" />
<asp:Parameter Name="Task" Type="String" />
<asp:ControlParameter ControlID="ComboPLCTestStand" DefaultValue="3" Name="teststand_ID" PropertyName="SelectedValue" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="Tasktype_ID" Type="Int32" />
<asp:Parameter Name="Date_Entered" Type="Datetime" />
<asp:Parameter Name="Originator_ID" Type="Int32" />
<asp:Parameter Name="Owner_ID" Type="Int32" />
<asp:Parameter Name="Task" Type="String" />
<asp:Parameter Name="Task_ID" Type="Int32"/>
<asp:Parameter Name="Complete" type="Boolean"/>
</UpdateParameters>
0

Rick
Top achievements
Rank 1
answered on 30 Mar 2015, 05:20 PM
This insert with hardcoded date works....
InsertCommand= " Insert into tasks (Date_Entered ,TaskType_ID , Originator_ID,Owner_ID ,Complete,Task ,Teststand_ID) values('03/25/2015' ,@Tasktype_ID,@Originator_ID, @Owner_ID,0,@Task,@teststand_ID)"
InsertCommand= " Insert into tasks (Date_Entered ,TaskType_ID , Originator_ID,Owner_ID ,Complete,Task ,Teststand_ID) values('03/25/2015' ,@Tasktype_ID,@Originator_ID, @Owner_ID,0,@Task,@teststand_ID)"
0
Hi Rick,
Could you verify whether the field is of type DateTime in your database? Also, does editing work with the modified configuration?
Alternatively, you can bring back the previous column and set the default value manually using the changeCellValue method:
http://www.telerik.com/help/aspnet-ajax/grid-batch-editing.html
Regards,
Eyup
Telerik
Could you verify whether the field is of type DateTime in your database? Also, does editing work with the modified configuration?
Alternatively, you can bring back the previous column and set the default value manually using the changeCellValue method:
http://www.telerik.com/help/aspnet-ajax/grid-batch-editing.html
Regards,
Eyup
Telerik
See What's Next in App Development. Register for TelerikNEXT.