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

Dropdown list selected value to display existing data stored

2 Answers 110 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ida
Top achievements
Rank 1
Ida asked on 10 Oct 2013, 03:29 PM

<

 

 

telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateEditColumn="True" CellSpacing="0" DataSourceID="objGetHaulsByTripcode" GridLines="Horizontal" AutoGenerateColumns="False">

 

 

 

 

 

 

 

<MasterTableView DataSourceID="objGetHaulsByTripcode">

 

 

 

 

 

 

 

<Columns>

 

 

 

 

 

 

 

<telerik:GridBoundColumn DataField="TripCode" FilterControlAltText="Filter TripCode column" HeaderText="TripCode" SortExpression="TripCode" UniqueName="TripCode"></telerik:GridBoundColumn>

 

 

 

 

 

 

 

<telerik:GridBoundColumn DataField="VessReg" FilterControlAltText="Filter VessReg column" HeaderText="VessReg" SortExpression="VessReg" UniqueName="VessReg"></telerik:GridBoundColumn>

 

 

 

 

 

 

 

<telerik:GridDropDownColumn DataField="TechniqueName" DataSourceID="getTechniques"

 

 

 

HeaderText="Technique" ListTextField="TechniqueFullName"

 

 

 

ListValueField="TechniqueCode" UniqueName="TechniqueName"

 

 

 

ColumnEditorID="TechniqueName" Reorderable="False"

 

 

 

Resizable="False"></telerik:GridDropDownColumn>

 

 

 

 

 

 

 

</Columns>

 

 

 

 

 

 

 

</MasterTableView>

 

 

 

 

 

 

 

</telerik:RadGrid>

 

 

 

 

 

 

 

 

<asp:SqlDataSource ID="objGetHaulsByTripcode" runat="server" ConnectionString="<%$ ConnectionStrings:FisheriesConnectionString %>"

 

 

 

SelectCommand="SELECT [TripCode], [VessReg], [TechniqueName] FROM [vwDisHaulsDetailsAll] WHERE ([TripCode] = @TripCode) ORDER BY [TripCode], [VessReg]">

 

 

 

 

 

 

 

<SelectParameters>

 

 

 

 

 

 

 

<asp:ControlParameter ControlID="ddlTripCode" Name="TripCode" PropertyName="SelectedValue" Type="String" />

 

 

 

 

 

 

 

</SelectParameters>

 

 

 

 

 

 

 

</asp:SqlDataSource>

 

 

 

 

 

 

 

 

<asp:SqlDataSource ID="getTechniques" runat="server" ConnectionString="<%$ ConnectionStrings:FisheriesConnectionString %>"

 

 

 

ProviderName="System.Data.SqlClient" SelectCommand="SELECT DisTechnique.Code AS [TechniqueCode], DisTechnique.Name AS [TechniqueFullName] FROM DisTechnique INNER JOIN DisGearTechniqueAllowed ON DisTechnique.Code = DisGearTechniqueAllowed.Code INNER JOIN DisTrips ON DisGearTechniqueAllowed.METHOD_CODE = DisTrips.GearCode WHERE ([TripCode] = @TripCode)">

 

 

 

 

 

 

 

<SelectParameters>

 

 

 

 

 

 

 

<asp:ControlParameter ControlID="ddlTripCode" Name="TripCode" PropertyName="SelectedValue" Type="String" />

 

 

 

 

 

 

 

</SelectParameters>

 

 

 

 

 

 

 

</asp:SqlDataSource>



Hi,

For my GridDropDownColumn DataField="TechniqueName" how can I show the [TechniqueName] FROM [vwDisHaulsDetailsAll] WHERE ([TripCode] = @TripCode) in the grid?

In select mode, the dropdown does not show anything in the row(s). I wish it to show what it stored in the database table, based on a TripCode.

Now, in Edit mode, it lists the 4 options ok. But I wish the selected value to be what has been already stored in the database for a row, based on a Trip Code.

Any advice please? Hope this question makes sense!

Thanks, Ida

 

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Oct 2013, 04:02 AM
Hi Ida,

Ensure that the fields specified through the DataField/ListValueField properties are of the same data type and the entries have a precise match.
The DataField property points to the column in the grid data-source containing values which will be compared at a later stage with the values available in the column, referenced by the ListValueField property.
The ListValueField points to the column in the table which will be used as a pointer to retrieve the items for the dropdown in the GridDropDownColumn.
The ListTextField points to the column in the table from which the grid will extract the values for the dropdown.
Please modify the code as below and see if it works,

ASPX:
<telerik:GridDropDownColumn DataField="TechniqueName" DataSourceID="getTechniques" HeaderText="Technique" ListTextField="TechniqueFullName" ListValueField="TechniqueName" UniqueName="TechniqueName" ColumnEditorID="TechniqueName" Reorderable="False" Resizable="False">
</
telerik:GridDropDownColumn>

When in edit mode it will display the corresponding value of that row.Please try and let me know if any concern.

Thanks,
Princy


0
Ida
Top achievements
Rank 1
answered on 11 Oct 2013, 08:02 AM
Brilliant! That helped.

Many thanks!
Tags
Grid
Asked by
Ida
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ida
Top achievements
Rank 1
Share this question
or