I have a Radgrid which displays a recordset with a lot of foreign key relations returned. Most of the values are the IDs of the rows, so I want to display the related descriptions from the lookup tables. To this I am using several GridDropDownColumns.
All of them work correctly with their respective sqldatasource bindings except the one that is dependent on another GridDropDownColumn. It seems that if I use the first dropdown as a <asp:controlpatameter... for the sqldatasource of the second dropdown ...then the Page Load cannot find the first dropdown.
Here is the sqldatasource for the second dropdown:
The error on PageLoad is:
Very little happens in the code-behind. I have tried some default value manipulation there, but it seems it only works on either the PageLoad or Add Record or Edit..... but never all three.
Please help.
Dana
All of them work correctly with their respective sqldatasource bindings except the one that is dependent on another GridDropDownColumn. It seems that if I use the first dropdown as a <asp:controlpatameter... for the sqldatasource of the second dropdown ...then the Page Load cannot find the first dropdown.
Here is the sqldatasource for the second dropdown:
<
asp:SqlDataSource
ID
=
"ds_DemoValues"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:CFSubsConn %>"<
br
><
br
>SelectCommand="SELECT [ID], [QuestionID], [Value] FROM [v_DemoValues] WHERE ([QuestionID] = @QuestionID) UNION SELECT Null AS ID, '' as QuestionID, 'Select a Value' AS [Value]"><
br
><
br
><
SelectParameters
> <
br
><
br
><
asp:controlparameter
name
=
"QuestionID"
controlid
=
"ddl_ParentControlID"
propertyname
=
"SelectedValue"
/> <
br
><
br
></
SelectParameters
><
br
><
br
></
asp:SqlDataSource
>
Could not find control 'ddl_ParentControlID' in ControlParameter 'QuestionID'.
The RadGrid code is as follows:<
telerik:RadGrid
ID
=
"RadGrid1"
AutoGenerateColumns
=
"False"
runat
=
"server"
Width
=
750px
DataSourceID
=
"ds_Validation"
GridLines
=
"None"
Skin
=
"Outlook"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
AllowAutomaticDeletes
=
"True"
>
<
MasterTableView
DataKeyNames
=
"OtherValidationID"
DataSourceID
=
"ds_Validation"
CommandItemDisplay
=
"Top"
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
<
table
id
=
"Table2"
cellspacing
=
"2"
cellpadding
=
"1"
width
=
"100%"
border
=
"1"
rules
=
"none"
style
=
"border-collapse: collapse; background: white;"
>
<
tr
class
=
"EditFormHeader"
>
<
td
style
=
"font-size: small"
><
b
>Validation Control Parameters</
b
></
td
></
tr
>
<
tr
> <
td
>
<
table
id
=
"Table3"
cellspacing
=
"1"
cellpadding
=
"1"
width
=
"250"
border
=
"0"
class
=
"module"
>
<
tr
><
td
></
td
><
td
></
td
></
tr
>
<
tr
>
<
td
>ID:</
td
>
<
td
><
asp:TextBox
ID
=
"TextBox1"
runat
=
"server"
Text='<%# Bind( "OTHERVALIDATIONID" ) %>' enabled="False"></
asp:TextBox
></
td
>
</
tr
>
<
tr
>
<
td
>ParentControlID:</
td
>
<
td
><
asp:DropDownList
ID
=
"ddl_ParentControlID"
AutoPostBack
=
"True"
OnSelectedIndexChanged
=
"setDemoValues"
runat
=
"server"
SelectedValue='<%# Bind("PARENTCONTROLID") %>' DataSourceID="ds_DemoQuestions" DataValueField="ID" DataTextField="Question"><
asp:ListItem
Value
=
""
Text
=
"Select an Question"
>Select an Question</
asp:ListItem
></
asp:DropDownList
></
td
>
</
tr
>
<
tr
>
<
td
>ParentControlType:</
td
>
<
td
><
asp:DropDownList
ID
=
"ddl_ParentControlType"
runat
=
"server"
SelectedValue='<%# Bind("PARENTCONTROLTYPE") %>' DataSourceID="ds_ControlTypes" DataValueField="VALUE" DataTextField="DESCRIPTION"></
asp:DropDownList
></
td
>
</
tr
>
<
tr
>
<
td
>DetailID:</
td
>
<
td
><
asp:DropDownList
ID
=
"ddl_DemoID"
DataSourceID
=
"ds_DemoValues"
runat
=
"server"
DataValueField
=
"ID"
DataTextField
=
"Value"
SelectedValue='<%# Bind("DetailID") %>' ><
asp:ListItem
Value
=
""
Text
=
"Select a Value"
>Select a Value</
asp:ListItem
></
asp:DropDownList
>
</
td
>
</
tr
>
<
tr
>
<
td
>ChildControlID:</
td
>
<
td
><
asp:DropDownList
ID
=
"ddl_ChildParentID"
runat
=
"server"
SelectedValue='<%# Bind("CHILDCONTROLID") %>' DataSourceID="ds_DemoQuestions" DataValueField="ID" DataTextField="Question">
<
asp:ListItem
Value
=
""
Text
=
"Select an Question"
>Select an Question</
asp:ListItem
></
asp:DropDownList
></
td
>
</
tr
>
<
tr
>
<
td
>ChildControlType:</
td
>
<
td
><
asp:DropDownList
ID
=
"ddl_ChildControlType"
runat
=
"server"
SelectedValue='<%# Bind("CHILDCONTROLTYPE") %>' DataSourceID="ds_ControlTypes" DataValueField="VALUE" DataTextField="DESCRIPTION">
</
asp:DropDownList
></
td
>
</
tr
>
<
tr
>
<
td
>ValidationMsg:</
td
>
<
td
><
asp:TextBox
ID
=
"TextBox3"
runat
=
"server"
Columns
=
"75"
Text='<%# Bind( "ValidationMsg") %>' TabIndex="2"></
asp:TextBox
></
td
>
</
tr
>
<
tr
>
<
td
><
asp:Button
ID
=
"btnUpdate"
Text='<%# IIf((TypeOf(Container) is Telerik.Web.Ui.GridEditFormInsertItem), "Insert", "Update") %>'
runat="server" CommandName='<%# IIf( DataBinder.Eval(Container, "OwnerTableView.IsItemInserted"), "PerformInsert", "Update") %>'>
</
asp:Button
></
td
>
<
td
><
asp:Button
ID
=
"btnCancel"
Text
=
"Cancel"
runat
=
"server"
CausesValidation
=
"False"
CommandName
=
"Cancel"
></
asp:Button
></
td
>
</
tr
>
</
table
>
</
td
>
</
tr
>
</
table
>
</
FormTemplate
>
<
EditColumn
UniqueName
=
"EditCommandColumn1"
></
EditColumn
>
</
EditFormSettings
>
<
Columns
>
<
telerik:GridEditCommandColumn
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridBoundColumn
DataField
=
"OtherValidationID"
DataType
=
"System.Int32"
HeaderText
=
"ID"
ReadOnly
=
"True"
SortExpression
=
"OtherValidationID"
UniqueName
=
"OtherValidationID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridDropDownColumn
DataField
=
"ParentControlID"
DataSourceID
=
"ds_DemoQuestions"
HeaderText
=
"Parent Question"
ListTextField
=
"QUESTION"
ListValueField
=
"ID"
UniqueName
=
"ParentControlID"
>
</
telerik:GridDropDownColumn
>
<
telerik:GridDropDownColumn
DataField
=
"ParentControlType"
DataSourceID
=
"ds_ControlTypes"
HeaderText
=
"ParentCtlType"
ListTextField
=
"DESCRIPTION"
ListValueField
=
"VALUE"
UniqueName
=
"ddl_ParentControlType"
>
</
telerik:GridDropDownColumn
>
<
telerik:GridDropDownColumn
DataField
=
"DetailID"
DataSourceID
=
"ds_DemoValues"
HeaderText
=
"DetailID"
ListTextField
=
"VALUE"
ListValueField
=
"ID"
UniqueName
=
"ddl_DemoID"
>
</
telerik:GridDropDownColumn
>
<
telerik:GridBoundColumn
DataField
=
"DetailID"
DataType
=
"System.Int32"
HeaderText
=
"DetailIDVal"
SortExpression
=
"DetailID"
UniqueName
=
"DetailID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ChildControlID"
DataType
=
"System.Int32"
HeaderText
=
"ChildControlID"
SortExpression
=
"ChildControlID"
UniqueName
=
"ChildControlID"
Display
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridDropDownColumn
DataField
=
"ChildControlID"
DataSourceID
=
"ds_DemoQuestions"
HeaderText
=
"Child Question"
ListTextField
=
"QUESTION"
ListValueField
=
"ID"
UniqueName
=
"ddl_ChildControlID"
>
</
telerik:GridDropDownColumn
>
<
telerik:GridBoundColumn
DataField
=
"Description"
DataType
=
"System.Int32"
HeaderText
=
"Description"
SortExpression
=
"Description"
UniqueName
=
"Description"
>
</
telerik:GridBoundColumn
>
<
telerik:GridDropDownColumn
DataField
=
"ChildControlType"
DataSourceID
=
"ds_ControlTypes"
HeaderText
=
"ChildCtlType"
ListTextField
=
"DESCRIPTION"
ListValueField
=
"VALUE"
UniqueName
=
"ddl_ChildControlType"
>
</
telerik:GridDropDownColumn
>
<
telerik:GridBoundColumn
DataField
=
"ValidationMsg"
HeaderText
=
"ValidationMsg"
SortExpression
=
"ValidationMsg"
UniqueName
=
"ValidationMsg"
>
</
telerik:GridBoundColumn
>
<
telerik:GridButtonColumn
CommandName
=
"Delete"
Text
=
"Delete"
UniqueName
=
"DeleteColumn"
>
<
ItemStyle
VerticalAlign
=
"Top"
/></
telerik:GridButtonColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
Very little happens in the code-behind. I have tried some default value manipulation there, but it seems it only works on either the PageLoad or Add Record or Edit..... but never all three.
Please help.
Dana