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

CommandItemDisplay button not working..

3 Answers 106 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
S
Top achievements
Rank 1
S asked on 19 Dec 2011, 06:03 PM
  <MasterTableView DataKeyNames="ID" CommandItemDisplay="TopAndBottom"  EditMode="PopUp" DataSourceID="DS1">


Hi,

I was using the above code for editing data with a pop-up.
My edit is working fine...but the add button...which appears when I Give Commanditemdisplay is not l working..It says the specific cast is Invalid...once I remove the date fields then i get the add button working...


My data field:

   <telerik:GridBoundColumn UniqueName="TechnicalDateofEntry" HeaderText="TechnicalDateofEntry" DataField="TechnicalDateofEntry" DataFormatString="{0:d}">


Edit template:
                            <td>
                               DateofEntry  
                            </td>
                            <td>
                                <telerik:RadDatePicker ID="TextBox17" runat="server"  SelectedDate='<%# Bind( "TechnicalDateofEntry") %>'>
                                </telerik:RadDatePicker>
                            </td>
                 
 <InsertParameters>
                  
                    <asp:Parameter Name="TechnicalDateofEntry" Type="DateTime" />
                   
                                       
                </InsertParameters>


.I have the attached error...plz let me know wats causing this issue..Am i missing casting anywhere...all I declared is date time..


Thanks a lot..

3 Answers, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 20 Dec 2011, 11:35 AM
Hello S,

// if you get error in insert Mode
SelectedDate='<%# (Container is GridEditFormInsertItem) ? null : Eval("StartDate") %>'>
 
// If you get error in edit mode
SelectedDate='<%# Eval("StartDate") == null ? null : Convert.ToDateTime(Eval("StartDate")) %>'


Thanks,
Jayesh Goyani
0
S
Top achievements
Rank 1
answered on 20 Dec 2011, 04:50 PM
Hi Jayesh,

I have only one Edit template which has the below code..

<tr>
                            <td>
                               TechnicalDateofEntry  
                            </td>
                            <td>
                                <telerik:RadDatePicker ID="RadDatePicker1" runat="server"  SelectedDate='<%# (Container is GridEditFormInsertItem) ? null : Eval("TechnicalDateofEntry") %>'>
                                </telerik:RadDatePicker>
                            </td>
                        </tr>

I tried ur code...but I was able to open the form When I click add...but unable to add or update the date ...I am getting the attached error..


I TRIED TO DO SOMETHING AT CODE BEHIND..as below

 protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
    {
        if (e.CommandName == "Edit")
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;
           RadDatePicker picker = (RadDatePicker)e.Item.FindControl("RadDatePicker1");
            //picker.SelectedDate="<%# (Container is GridEditFormInsertItem) ? null : Eval("StartDate") %>";
}

I am getting null into the picker object...


Please advise..will be of gr8 help..

0
S
Top achievements
Rank 1
answered on 20 Dec 2011, 07:58 PM
ASPX:
 <telerik:RadDatePicker ID="dtStart" runat="server" Width="200px" DbSelectedDate='<%# Bind("StartDate") %>'/> 


Tried DbSelected date instead of selected..it worked..awesome..thanks
Tags
General Discussions
Asked by
S
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
S
Top achievements
Rank 1
Share this question
or