Hi There,
I've been trying achieve the following, but could not get it done. Looking for any of your help.
But, County column is related to State. When the grid is bound with DataSource, I need to display State Name and County Name in place of their IDs (Database record would have StateID & CountyID). That's the reason I chose Dropdown columns. so that I can have simple text rendered in view mode.
Here is what I'm doing..
Observation:
I found that, ODS Selecting event first only once (when the grid was bound), but not for all the rows.
Note: I need grid only in view mode. Not editing rows in grid.
I tried having template columns, but could not find - how to display the county name for the corresponding id. (I do not want Combo box to be displayed, only county name has to be displayed)
Pls give your helping hand to pass out from this hurdle.
If you have any other solution, pls pass it to.
Counting upon the positive response..
I've been trying achieve the following, but could not get it done. Looking for any of your help.
- Have two dropdown column in grid (State & County)
- State column is bound with Object DataSource
- County column is also bound with another Object DataSource.
But, County column is related to State. When the grid is bound with DataSource, I need to display State Name and County Name in place of their IDs (Database record would have StateID & CountyID). That's the reason I chose Dropdown columns. so that I can have simple text rendered in view mode.
Here is what I'm doing..
- Assign DataSource to the grid at runtime.
- In the grid ItemCreated event, passing the current row's StateID to the County ODS SelectParameter.
Observation:
- For the first row, I'm getting the County Name displayed
- But for the second row, its empty.
I found that, ODS Selecting event first only once (when the grid was bound), but not for all the rows.
Note: I need grid only in view mode. Not editing rows in grid.
I tried having template columns, but could not find - how to display the county name for the corresponding id. (I do not want Combo box to be displayed, only county name has to be displayed)
Pls give your helping hand to pass out from this hurdle.
If you have any other solution, pls pass it to.
Counting upon the positive response..
<
telerik:GridDropDownColumn
DataField
=
"StateID"
DataSourceID
=
"odsState"
FilterControlAltText
=
"Filter StateID column"
HeaderText
=
"State"
ListTextField
=
"DisplayText"
ListValueField
=
"ValueText"
UniqueName
=
"StateID"
>
</
telerik:GridDropDownColumn
>
<
telerik:GridDropDownColumn
DataField
=
"CountyID"
DataSourceID
=
"odsCounty"
FilterControlAltText
=
"Filter CountyID column"
HeaderText
=
"County"
ListTextField
=
"DisplayText"
ListValueField
=
"ValueText"
UniqueName
=
"CountyID"
>
</
telerik:GridDropDownColumn
>
<
asp:ObjectDataSource
ID
=
"odsState"
runat
=
"server"
SelectMethod
=
"GetStates"
TypeName
=
"MyBLL"
>
</
asp:ObjectDataSource
>
<
asp:ObjectDataSource
ID
=
"odsCounty"
runat
=
"server"
SelectMethod
=
"GetCounties"
TypeName
=
"MyBLL"
>
<
SelectParameters
>
<
asp:Parameter
Name
=
"stateID"
Type
=
"String"
/>
</
SelectParameters
>
</
asp:ObjectDataSource
>
protected
void
grid_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
odsCounty.SelectParameters[
"stateSaid"
].DefaultValue =
"I'm assigning the currect row's state ID here"
;
//Assuming that for every row, ods selecting event would fire. But its not happening
}