I have a radgrid that displays a date from a record in a database along with the other information in that record. What I want to do is automatically populate that date with the current date when a user enters a new row - AND I want that date to show up on the screen before they insert it. I know how to populate the column at the time of insert, but what I would like is when a user presses "Add new record" that a Label shows in the Edit form with the current date.
Here is my code:
What event do I put that in? ItemCommand fires at the right time, but I don't seem to be able to reference CurrDateLbl in that event.
Eric
Here is my code:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" |
DataSourceID="LogBookODS" GridLines="None" AllowFilteringByColumn="True" |
AllowPaging="True" AllowSorting="True" AllowAutomaticDeletes="True" |
AllowAutomaticInserts="True" AllowAutomaticUpdates="True" |
Skin="Office2007"> |
<MasterTableView DataKeyNames="LogBookID" DataSourceID="LogBookODS" |
CommandItemDisplay="Top"> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</ExpandCollapseColumn> |
<Columns> |
<telerik:GridBoundColumn DataField="LogBookID" DataType="System.Int32" |
HeaderText="LogBookID" ReadOnly="True" SortExpression="LogBookID" |
UniqueName="LogBookID" Visible="False"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="PatientID" DataType="System.Int32" |
HeaderText="PatientID" SortExpression="PatientID" UniqueName="PatientID" |
Visible="False" ReadOnly="True"> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn DataField="LogEntryDate" DataType="System.DateTime" |
HeaderText="Entry Date" SortExpression="LogEntryDate" |
UniqueName="LogEntryDate"> |
<EditItemTemplate> |
<asp:Label ID="CurrDateLbl" runat="server"></asp:Label> |
<asp:TextBox ID="CurrDateTxtBx" runat="server" Visible="false" Text='<%# Bind("LogEntryDate") %>'></asp:TextBox> |
</EditItemTemplate> |
<ItemTemplate> |
<asp:Label ID="LogEntryDateLabel" runat="server" |
Text='<%# Eval("LogEntryDate","{0:d}") %>'></asp:Label> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridBoundColumn DataField="LogDescription" HeaderText="Description " |
MaxLength="100" UniqueName="LogDescription"> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn DataField="LogEntry" HeaderText="Log Entry" |
SortExpression="LogEntry" UniqueName="LogEntry" AllowFiltering="False"> |
<EditItemTemplate> |
<br /> |
<telerik:RadEditor ID="RadEditor1" Runat="server" |
Content='<%# Bind("LogEntry") %>'> |
<Content> |
</Content> |
</telerik:RadEditor> |
</EditItemTemplate> |
<ItemTemplate> |
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="Edit" ImageUrl="~/images/Edit.gif" ToolTip="Click to view the log entry" /> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridButtonColumn ConfirmText="Delete this Entry?" ConfirmDialogType="RadWindow" |
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" |
UniqueName="DeleteColumn"> |
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" /> |
</telerik:GridButtonColumn> |
</Columns> |
<EditFormSettings> |
<EditColumn UniqueName="EditCommandColumn1" ButtonType="ImageButton"></EditColumn> |
</EditFormSettings> |
</MasterTableView> |
</telerik:RadGrid> |
What I would like is for CurrDateLbl to have the current date in it when the user clicks "Add New Record"
What event do I put that in? ItemCommand fires at the right time, but I don't seem to be able to reference CurrDateLbl in that event.
Eric