I have a radgrid and in the edit template form I have a table which contains textboxes,dropdowns, raddatepickers
Textboxes are binding data fine, but the raddate pickers , dropdowns are not binding data properly,
Can you look at the below code and let me know what am I doing wrong?
DBselectedDate is not binding date at all
Also here is my dropdownlist code
If I add selectedvalue to the dropdownlist and click on edit button on the rad grid the edit form is not even showing up. when I delete selectedValue then only I can see the edit form and the text boxes with proper data.
What Am I doing wrong? (All the data for the dropdowns and raddatepickers are binding from database)
Textboxes are binding data fine, but the raddate pickers , dropdowns are not binding data properly,
Can you look at the below code and let me know what am I doing wrong?
DBselectedDate is not binding date at all
<
td
align
=
"left"
>
<
telerik:RadDatePicker
ID
=
"txtEditEndDate"
runat
=
"server"
DbSelectedDate='<%# Bind("EndDate") %>'>
<
Calendar
ID
=
"Calendar4"
runat
=
"server"
UseRowHeadersAsSelectors
=
"False"
UseColumnHeadersAsSelectors
=
"False"
ViewSelectorText
=
"x"
>
<
SpecialDays
>
<
telerik:RadCalendarDay
Repeatable
=
"Today"
>
<
ItemStyle
BackColor
=
"Pink"
/>
</
telerik:RadCalendarDay
>
</
SpecialDays
>
</
Calendar
>
</
telerik:RadDatePicker
>
Also here is my dropdownlist code
<
asp:DropDownList
ID
=
"ddlEditMember"
runat
=
"server"
CssClass
=
"genericControl"
SelectedValue='<%# Bind("Member") %>' />
If I add selectedvalue to the dropdownlist and click on edit button on the rad grid the edit form is not even showing up. when I delete selectedValue then only I can see the edit form and the text boxes with proper data.
What Am I doing wrong? (All the data for the dropdowns and raddatepickers are binding from database)
6 Answers, 1 is accepted
0

Sima
Top achievements
Rank 1
answered on 31 Jul 2012, 04:48 PM
When I added mindate="2012/1/1" before DBSelecteddate='<%# Bind("date")%>' - All My RadDatePickers are showing the binded date.
How can I make mindate ="Datetime.now" ?
How can I make mindate ="Datetime.now" ?
0

Shinu
Top achievements
Rank 2
answered on 01 Aug 2012, 09:03 AM
Hello,
You can access the controls in edit mode and set the selected value in dropdownlist and mindate in datepicker as shown below.
C#:
Thanks,
Shinu.
You can access the controls in edit mode and set the selected value in dropdownlist and mindate in datepicker as shown below.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = (GridEditableItem)e.Item;
DropDownList ddl = (DropDownList)item.FindControl(
"ddlEditMember"
);
RadDatePicker pkr = (RadDatePicker)item.FindControl(
"txtEditEndDate"
);
pkr.MinDate = DateTime.Now;
//setting mindate in datepicker
ddl.SelectedValue = (
string
)DataBinder.Eval(e.Item.DataItem,
"FirstName"
).ToString();
//setting the selected value in dropdownlist
}
}
Thanks,
Shinu.
0

Sima
Top achievements
Rank 1
answered on 02 Aug 2012, 02:47 PM
Hi Shinu,
I am using VB.net. When I added the below code trying to find the control
If TypeOf e.Item Is GridDataItem Then
ElseIf (TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode) Then
Dim Id As Label = CType(e.Item.FindControl("lbId"), Label)
Dim list As DropDownList = CType(e.Item.FindControl("ddlMember"), DropDownList)
Using dc1 as new TestAppDatacontext()
// Dim query = (from p in dc1.TblMems where p.memId=convert.Toint32(Id.text)) select p).singleorDefault()
Dim query = (from p in dc1.TblMems where p.memId=convert.Toint32(Id.text)) select p.Member)
list.datasource=query
list.datatextfield="Member"
list.datavaluefield="member"
list.datasource=query
I am getting the data inside Id, I am seeing data inside query.Member1 but list.selectedvalue is always coming =""
also if I add list.databind() also I click on edit button the edit form template is not opening. What Am I missing??
End Using
End If
When I put a break point in the response.write it is never going inside the loop , Is in edit mode is always coming false.
I am using VB.net. When I added the below code trying to find the control
Private Sub rdSubmit_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rdSubmit.ItemDataBound
If TypeOf e.Item Is GridDataItem Then
ElseIf (TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode) Then
Dim Id As Label = CType(e.Item.FindControl("lbId"), Label)
Dim list As DropDownList = CType(e.Item.FindControl("ddlMember"), DropDownList)
Using dc1 as new TestAppDatacontext()
// Dim query = (from p in dc1.TblMems where p.memId=convert.Toint32(Id.text)) select p).singleorDefault()
Dim query = (from p in dc1.TblMems where p.memId=convert.Toint32(Id.text)) select p.Member)
list.datasource=query
list.datatextfield="Member"
list.datavaluefield="member"
list.datasource=query
I am getting the data inside Id, I am seeing data inside query.Member1 but list.selectedvalue is always coming =""
also if I add list.databind() also I click on edit button the edit form template is not opening. What Am I missing??
End Using
End If
End sub
When I put a break point in the response.write it is never going inside the loop , Is in edit mode is always coming false.
0

Shinu
Top achievements
Rank 2
answered on 03 Aug 2012, 08:51 AM
Hello,
Unfortunately I cannot reproduce the issue at my end. Here is the code that I tried which worked as expected.
aspx:
VB:
Thanks,
Shinu.
Unfortunately I cannot reproduce the issue at my end. Here is the code that I tried which worked as expected.
aspx:
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
<
telerik:RadDatePicker
ID
=
"txtEditEndDate"
runat
=
"server"
DbSelectedDate='<%# Bind("BirthDate") %>'>
<
Calendar
ID
=
"Calendar4"
runat
=
"server"
UseRowHeadersAsSelectors
=
"False"
UseColumnHeadersAsSelectors
=
"False"
ViewSelectorText
=
"x"
>
<
SpecialDays
>
<
telerik:RadCalendarDay
Repeatable
=
"Today"
>
<
ItemStyle
BackColor
=
"Pink"
/>
</
telerik:RadCalendarDay
>
</
SpecialDays
>
</
Calendar
>
</
telerik:RadDatePicker
>
<
asp:DropDownList
ID
=
"ddlEditMember"
DataSourceID
=
"SqlDataSource1"
DataTextField
=
"FirstName"
DataValueField
=
"FirstName"
runat
=
"server"
/>
</
FormTemplate
>
</
EditFormSettings
>
VB:
Protected
Sub
RadGrid1_ItemDataBound(sender
As
Object
, e
As
GridItemEventArgs)
If
TypeOf
e.Item
Is
GridEditableItem
AndAlso
e.Item.IsInEditMode
Then
Dim
item
As
GridEditableItem =
DirectCast
(e.Item, GridEditableItem)
Dim
ddl
As
DropDownList =
DirectCast
(item.FindControl(
"ddlEditMember"
), DropDownList)
Dim
pkr
As
RadDatePicker =
DirectCast
(item.FindControl(
"txtEditEndDate"
), RadDatePicker)
pkr.MinDate = DateTime.Now
ddl.SelectedValue =
DirectCast
(DataBinder.Eval(e.Item.DataItem,
"FirstName"
).ToString(),
String
)
End
If
End
Sub
Thanks,
Shinu.
0

Sima
Top achievements
Rank 1
answered on 03 Aug 2012, 02:50 PM
Hi Shinu,
I am able to access the Radatepicker on the .vb side now the problem is if I click Edit on the grid view The form inside the edit item Template is opening. Everythingworks except the RaddatePicker.
1. When I click on the calendar button The calendar is not popping up
2. When I manually enter the data in the textbox and clicks on Update still it is getting the old date (because I am pulling the radpcker.Selecteddate)
How can I rectify these 2 issues? I tried your direct cast it didn't work.
Thanks,
Sima
I am able to access the Radatepicker on the .vb side now the problem is if I click Edit on the grid view The form inside the edit item Template is opening. Everythingworks except the RaddatePicker.
1. When I click on the calendar button The calendar is not popping up
2. When I manually enter the data in the textbox and clicks on Update still it is getting the old date (because I am pulling the radpcker.Selecteddate)
How can I rectify these 2 issues? I tried your direct cast it didn't work.
Thanks,
Sima
0

Sima
Top achievements
Rank 1
answered on 03 Aug 2012, 04:44 PM
I have a <telerik:RadAjaxManager> in my code for my radgrid. When I commented out this block all my rad datepickers inside the edit template column are working.