Hello all
I have the following RadGrid, where i have an EditForm template for editing and inserting, well, the Update command is working fine, however, when using SelectedValue in the DropDownList the insert form will not show when i click add new record, and when i remove the SelectedValue property, the insert form shows but wont work when i insert data, i double checked my sql statement for inserting and it works fine.
Any suggestions?
I have the following RadGrid, where i have an EditForm template for editing and inserting, well, the Update command is working fine, however, when using SelectedValue in the DropDownList the insert form will not show when i click add new record, and when i remove the SelectedValue property, the insert form shows but wont work when i insert data, i double checked my sql statement for inserting and it works fine.
Any suggestions?
<
telerik:RadGrid
ID
=
"GridStaff"
runat
=
"server"
ShowStatusBar
=
"True"
OnItemCommand
=
"GridStaff_ItemCommand"
OnItemUpdated
=
"GridStaff_ItemUpdated"
OnItemCreated
=
"GridStaff_ItemCreated"
OnUpdateCommand
=
"GridStaff_UpdateCommand"
OnItemInserted
=
"GridStaff_ItemInserted"
OnInsertCommand
=
"GridStaff_InsertCommand"
OnPreRender
=
"GridStaff_PreRender"
AutoGenerateColumns
=
"False"
PageSize
=
"20"
AllowSorting
=
"True"
AllowAutomaticInserts
=
"True"
AllowPaging
=
"True"
DataSourceID
=
"SqlDataSourceStaff"
AllowAutomaticDeletes
=
"true"
OnItemDataBound
=
"GridStaff_ItemDataBound"
AllowAutomaticUpdates
=
"True"
Width
=
"835px"
FilterType
=
"CheckedList"
AllowFilteringByColumn
=
"True"
GridLines
=
"None"
CellSpacing
=
"0"
>
<
ExportSettings
>
<
Pdf
>
<
PageHeader
>
<
LeftCell
Text
=
""
/>
<
MiddleCell
Text
=
""
/>
<
RightCell
Text
=
""
/>
</
PageHeader
>
<
PageFooter
>
<
LeftCell
Text
=
""
/>
<
MiddleCell
Text
=
""
/>
<
RightCell
Text
=
""
/>
</
PageFooter
>
</
Pdf
>
</
ExportSettings
>
<
MasterTableView
DataSourceID
=
"SqlDataSourceStaff"
InsertItemDisplay
=
"Top"
InsertItemPageIndexAction
=
"ShowItemOnFirstPage"
DataKeyNames
=
"UserID"
EditMode
=
"EditForms"
AutoGenerateColumns
=
"false"
AllowMultiColumnSorting
=
"False"
Width
=
"100%"
CommandItemDisplay
=
"Top"
Name
=
"admStaff"
>
<
CommandItemSettings
ShowAddNewRecordButton
=
"true"
AddNewRecordText
=
"Add New Staff Member"
ShowExportToPdfButton
=
"true"
/>
<
RowIndicatorColumn
FilterControlAltText
=
"Filter RowIndicator column"
Visible
=
"True"
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
FilterControlAltText
=
"Filter ExpandColumn column"
Visible
=
"True"
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
UniqueName
=
"EditCommandColumn"
>
<
HeaderStyle
Width
=
"20px"
>
</
HeaderStyle
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"UserID"
ShowFilterIcon
=
"false"
AllowFiltering
=
"false"
HeaderText
=
"#"
HeaderButtonType
=
"TextButton"
DataField
=
"UserID"
UniqueName
=
"UserID"
MaxLength
=
"7"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"EnglishName"
HeaderText
=
"Name"
HeaderButtonType
=
"TextButton"
DataField
=
"EnglishName"
UniqueName
=
"EnglishName"
MaxLength
=
"40"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"Subject"
HeaderText
=
"Subject"
HeaderButtonType
=
"TextButton"
DataField
=
"SubEn"
UniqueName
=
"Subject"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"DepEn"
HeaderText
=
"Department"
HeaderButtonType
=
"TextButton"
DataField
=
"DepartID"
UniqueName
=
"DepEn"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Load/Week"
UniqueName
=
"TLoad"
AllowFiltering
=
"false"
>
<
ItemStyle
Width
=
"20px"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblTeacherLoad"
runat
=
"server"
></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"PhoneNumber"
HeaderText
=
"PhoneNumber"
HeaderButtonType
=
"TextButton"
AllowFiltering
=
"false"
DataField
=
"PhoneNumber"
UniqueName
=
"PhoneNumber"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"MSG"
UniqueName
=
"SendMSG"
AllowFiltering
=
"false"
>
<
ItemStyle
Width
=
"20px"
/>
<
ItemTemplate
>
<
asp:ImageButton
ID
=
"img_SendMSG"
runat
=
"server"
CommandName
=
"SendMsgToStaff"
ImageUrl
=
"~/images/sendmsgicon.png"
CommandArgument='<%# Bind("UserID") %>' Width="20px" Height="20px" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"SMS"
UniqueName
=
"SendSMS"
AllowFiltering
=
"false"
>
<
ItemStyle
Width
=
"20px"
/>
<
ItemTemplate
>
<
asp:ImageButton
ID
=
"img_SendSMS"
runat
=
"server"
CommandName
=
"SendSmsToStaff"
ImageUrl
=
"~/images/sendsmsicon.png"
CommandArgument='<%# Bind("UserID") %>' Width="20px" Height="20px" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
<
EditFormSettings
EditFormType
=
"Template"
PopUpSettings-Modal
=
"true"
>
<
FormTemplate
>
<
div
class
=
"register"
>
<
div
class
=
"divClass"
>
<
fieldset
class
=
"rowPersonalEn"
>
<
legend
>Personal Details
</
legend
>
<
p
>
<
label
>User ID
</
label
>
<
asp:TextBox
ID
=
"txtUserID"
CssClass
=
"long"
Text='<%# Bind("UserID") %>' Enabled="false" runat="server"></
asp:TextBox
>
</
p
>
<
p
>
<
label
>First Name
</
label
>
<
asp:TextBox
ID
=
"txtFirstNameEn"
CssClass
=
"long"
Text='<%# Bind("FirstNameEn") %>' runat="server"></
asp:TextBox
>
</
p
>
<
p
>
<
label
>Second Name
</
label
>
<
asp:TextBox
ID
=
"txtSecondNameEn"
CssClass
=
"long"
Text='<%# Bind("SecondNameEn") %>' runat="server"></
asp:TextBox
>
</
p
>
<
p
>
<
label
>Family Name
</
label
>
<
asp:TextBox
ID
=
"txtFamilyNameEn"
CssClass
=
"long"
Text='<%# Bind("FamilyNameEn") %>' runat="server"></
asp:TextBox
>
</
p
>
<
p
>
<
label
>Date of Birth
</
label
>
<
asp:TextBox
ID
=
"txtDOB"
CssClass
=
"long"
Text='<%# Bind("DOB") %>' runat="server"></
asp:TextBox
>
</
p
>
<
p
>
<
label
>Nationality
</
label
>
<
asp:DropDownList
ID
=
"ddlNationality"
runat
=
"server"
>
</
asp:DropDownList
>
</
p
>
<
p
>
<
label
>ID No.
</
label
>
<
asp:TextBox
ID
=
"txtIDNo"
CssClass
=
"long"
Text='<%# Bind("IDNo") %>' runat="server"></
asp:TextBox
>
</
p
>
<
p
>
<
label
>Mobile
</
label
>
<
asp:TextBox
ID
=
"txtMobile"
CssClass
=
"long"
Text='<%# Bind("PhoneNumber") %>' runat="server"></
asp:TextBox
>
</
p
>
<
p
>
<
label
>Email
</
label
>
<
asp:TextBox
ID
=
"txtEmail"
CssClass
=
"long"
Text='<%# Bind("Email") %>' runat="server"></
asp:TextBox
>
</
p
>
<
p
>
<
label
>Notes
</
label
>
<
asp:TextBox
ID
=
"txtNotes"
TextMode
=
"MultiLine"
Text='<%# Bind("Notes") %>' CssClass="multi" runat="server"></
asp:TextBox
>
</
p
>
</
fieldset
>
<
fieldset
class
=
"rowPersonalAr"
>
<
legend
>المعلومات الشخصية</
legend
>
<
p
style
=
"text-align:left"
>
<
asp:TextBox
ID
=
"txtFirstNameAr"
CssClass
=
"long"
Text='<%# Bind("FirstNameAr") %>' runat="server"></
asp:TextBox
>
<
label
>الاسم الأول
</
label
>
</
p
>
<
p
>
<
asp:TextBox
ID
=
"txtSecondNameAr"
CssClass
=
"long"
Text='<%# Bind("SecondNameAr") %>' runat="server"></
asp:TextBox
>
<
label
>الاسم الثاني
</
label
>
</
p
>
<
p
>
<
asp:TextBox
ID
=
"txtFamilyNameAr"
CssClass
=
"long"
Text='<%# Bind("FamilyNameAr") %>' runat="server"></
asp:TextBox
>
<
label
>العائلة
</
label
>
</
p
>
</
fieldset
>
<
fieldset
class
=
"rowAcademical"
>
<
legend
>Academical Information
</
legend
>
<
p
>
<
label
>Degree</
label
>
<
asp:DropDownList
ID
=
"ddlAcademicDegree"
runat
=
"server"
DataSourceID
=
"DataSourceAD"
DataTextField
=
"ADEn"
DataValueField
=
"ADID"
AppendDataBoundItems
=
"true"
>
<
asp:ListItem
Selected
=
"True"
Text
=
"Select"
Value
=
"0"
></
asp:ListItem
>
</
asp:DropDownList
>
</
p
>
<
p
>
<
label
>Experience
</
label
>
<
asp:TextBox
ID
=
"txtExp"
CssClass
=
"long"
Text='<%# Bind("YearsOfExp") %>' runat="server"></
asp:TextBox
>
</
p
>
<
p
>
<
label
>College/Uni.
</
label
>
<
asp:TextBox
ID
=
"txtUniv"
CssClass
=
"long"
Text='<%# Bind("CollegeName") %>' runat="server"></
asp:TextBox
>
</
p
>
<
p
>
<
label
>Department</
label
>
<
asp:DropDownList
ID
=
"ddlDept"
runat
=
"server"
DataSourceID
=
"DataSourceDepartments"
DataTextField
=
"DepartmentEn"
DataValueField
=
"DepartmentID"
AppendDataBoundItems
=
"true"
>
<
asp:ListItem
Selected
=
"True"
Text
=
"Select"
Value
=
"0"
>
</
asp:ListItem
>
</
asp:DropDownList
>
</
p
>
<
p
>
<
label
>Stage</
label
>
<
asp:DropDownList
ID
=
"ddlStage"
runat
=
"server"
DataSourceID
=
"DataSourceStages"
DataTextField
=
"StageEn"
DataValueField
=
"StageID"
AppendDataBoundItems
=
"true"
>
<
asp:ListItem
Selected
=
"True"
Text
=
"Select"
Value
=
"0"
></
asp:ListItem
>
</
asp:DropDownList
>
</
p
>
<
p
>
<
label
>Subject</
label
>
<
asp:DropDownList
ID
=
"ddlSubject"
runat
=
"server"
DataSourceID
=
"DataSourceSubjects"
DataTextField
=
"SubEn"
DataValueField
=
"SubID"
AppendDataBoundItems
=
"true"
>
<
asp:ListItem
Selected
=
"True"
Text
=
"Select"
Value
=
"0"
></
asp:ListItem
>
</
asp:DropDownList
>
</
p
>
<
p
>
<
label
>Hired Date</
label
>
<
asp:TextBox
ID
=
"txtHireDate"
CssClass
=
"long"
Text='<%# Bind("HiredDate") %>' runat="server"></
asp:TextBox
>
</
p
>
</
fieldset
>
<
div
>
<
asp:Button
ID
=
"btnUpdate"
Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
runat="server" CommandName="Update">
</
asp:Button
>
<
asp:Button
ID
=
"btnCancel"
Text
=
"Close"
runat
=
"server"
CausesValidation
=
"False"
CommandName
=
"Cancel"
></
asp:Button
>
</
div
>
</
div
>
</
div
>
</
FormTemplate
>
</
EditFormSettings
>
<
BatchEditingSettings
EditType
=
"Cell"
/>
<
PagerStyle
AlwaysVisible
=
"True"
PageSizeControlType
=
"RadComboBox"
/>
</
MasterTableView
>
<
PagerStyle
AlwaysVisible
=
"True"
PageSizeControlType
=
"RadComboBox"
/>
<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SqlDataSourceStaff"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:EschoolTestV2ConnectionString %>"
SelectCommand="SELECT usr.*, usr.FirstNameEn+' '+usr.FamilyNameEn AS EnglishName, dept.DepEn AS DepartID,dept.DepID AS DeparID,sub.SubEn,sub.SubID, ad.ADEn,st.StageEn FROM AttUsers usr,AttStages st, AttAcademicalDegrees ad, AttDepartments dept, AttSubjects sub WHERE st.StageID=usr.Stage AND ad.ADID=usr.AcademicalDegree AND sub.SubID=usr.Subject AND usr.Department=dept.DepID"
UpdateCommand="UPDATE AttUsers SET [FirstNameEn]=@FirstNameEn, [FirstNameAr]=@FirstNameAr, [SecondNameEn]=@SecondNameEn,[SecondNameAr]=@SecondNameAr,[FamilyNameEn]=@FamilyNameEn,[FamilyNameAr]=@FamilyNameAr,[DOB]=@DOB,[IDNo]=IDNo,[PhoneNumber]=@PhoneNumber,[Email]=@Email,[Notes]=@Notes,[YearsOfExp]=@YearsOfExp,[CollegeName]=@CollegeName,[Department]=@DeparID,[Subject]=@Subject,[AcademicalDegree]=@AcademicalDegree,[Stage]=@Stage,[HiredDate]=@HiredDate WHERE UserID=@UserID"
InsertCommand="INSERT INTO AttUsers (FirstNameAr,SecondNameAr,FamilyNameAr,FirstNameEn,SecondNameEn,FamilyNameEn,DOB,IDNo,PhoneNumber,Email,Notes,YearsOfExp,CollegeName,Department,Subject,AcademicalDegree,Stage,HiredDate) VALUES (@FirstNameAr,@SecondNameAr,@FamilyNameAr,@FirstNameEn,@SecondNameEn,@FamilyNameEn,@DOB,@IDNo,@PhoneNumber,@Email,@Notes,@YearsOfExp,@CollegeName,@DeparID,@Subject,@AcademicalDegree,@Stage,@HiredDate)">
<
UpdateParameters
>
<
asp:Parameter
Name
=
"UserID"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"FirstNameAr"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"FirstNameEn"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"SecondNameAr"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"SecondNameEn"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"FamilyNameAr"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"FamilyNameEn"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"DOB"
Type
=
"DateTime"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"IDNo"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"PhoneNumber"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Email"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Notes"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"YearsOfExp"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CollegeName"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"DeparID"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Subject"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"AcademicalDegree"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"HiredDate"
Type
=
"DateTime"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Stage"
Type
=
"String"
/>
</
UpdateParameters
>
<
InsertParameters
>
<
asp:Parameter
Name
=
"FirstNameAr"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"FirstNameEn"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"SecondNameAr"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"SecondNameEn"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"FamilyNameAr"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"FamilyNameEn"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"DOB"
Type
=
"DateTime"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"IDNo"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"PhoneNumber"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Email"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Notes"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"YearsOfExp"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"CollegeName"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"DeparID"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Subject"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"Stage"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"AcademicalDegree"
Type
=
"String"
></
asp:Parameter
>
<
asp:Parameter
Name
=
"HiredDate"
Type
=
"DateTime"
></
asp:Parameter
>
</
InsertParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"DataSourceDepartments"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:EschoolTestV2ConnectionString %>"
SelectCommand="SELECT DepEn AS DepartmentEn, DepID AS DepartmentID FROM AttDepartments ORDER BY DepID ASC">
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"DataSourceSubjects"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:EschoolTestV2ConnectionString %>"
SelectCommand="SELECT SubEn, SubID FROM AttSubjects ORDER BY SubID ASC">
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"DataSourceAD"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:EschoolTestV2ConnectionString %>"
SelectCommand="SELECT ADID, ADEn FROM AttAcademicalDegrees ORDER BY ADID ASC">
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"DataSourceStages"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:EschoolTestV2ConnectionString %>"
SelectCommand="SELECT StageID, StageEn FROM AttStages ORDER BY StageID ASC">
</
asp:SqlDataSource
>