G
Guest
Hi,
I am trying to bind the selected value of a databound dropdown box in a
databound gridview control to the value being displayed in the template
column the dropdown box has been added to. Both the grid and the dropdown
box are retrieving and displaying data fine, I just cant bind the two
together.
I followed the instructions in the help document called 'Walkthrough:
Displaying a Drop-Down List While Editing in the GridView Web Server Control'
and the behavior I am getting is not as described in the help document.
After setting the ODS for both the gridview and the dropdown list (which was
added in an editItemTemplate), I went in to the DropDownList Tasks menu,
chose Edit DataBindings, but when I expected to modify the 'Binding for
Selected Value' options, they were greyed out (disabled). The ONLY available
method was the custom binding expression.
How can I get the 'Binding for Selected Value' options enabled? What am I
missing?
OR, what would be the Custom binding expression I should use to make it work.
Below is the code I am using. The control is the ddCountryRegion.
<asp:GridView ID="gvData" runat="server" CssClass="main-result-grid"
AutoGenerateColumns="False" DataSourceID="odsData">
<Columns>
<asp:BoundField DataField="CountryCode"
HeaderText="CountryCode" />
<asp:BoundField DataField="CountryName"
HeaderText="CountryName" />
<asp:BoundField DataField="BaseCurrency"
HeaderText="BaseCurrency" />
<asp:TemplateField HeaderText="CountryRegion">
<EditItemTemplate>
<aspropDownList ID="ddCountryRegion"
runat="server" DataSourceID="odsRegionCol" DataTextField="key"
DataValueField="value">
</aspropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblCountryRegion"
runat="server" Text='<%# Bind("CountryRegion") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="WonCountry"
HeaderText="WonCountry" />
<asp:BoundField DataField="PrimaryIndex"
HeaderText="PrimaryIndex" />
<asp:CommandField ShowEditButton="True" />
</Columns>
<EmptyDataTemplate>
No Country Information has been found.
</EmptyDataTemplate>
</asp:GridView>
Thanks in advance for your help,
Dean
I am trying to bind the selected value of a databound dropdown box in a
databound gridview control to the value being displayed in the template
column the dropdown box has been added to. Both the grid and the dropdown
box are retrieving and displaying data fine, I just cant bind the two
together.
I followed the instructions in the help document called 'Walkthrough:
Displaying a Drop-Down List While Editing in the GridView Web Server Control'
and the behavior I am getting is not as described in the help document.
After setting the ODS for both the gridview and the dropdown list (which was
added in an editItemTemplate), I went in to the DropDownList Tasks menu,
chose Edit DataBindings, but when I expected to modify the 'Binding for
Selected Value' options, they were greyed out (disabled). The ONLY available
method was the custom binding expression.
How can I get the 'Binding for Selected Value' options enabled? What am I
missing?
OR, what would be the Custom binding expression I should use to make it work.
Below is the code I am using. The control is the ddCountryRegion.
<asp:GridView ID="gvData" runat="server" CssClass="main-result-grid"
AutoGenerateColumns="False" DataSourceID="odsData">
<Columns>
<asp:BoundField DataField="CountryCode"
HeaderText="CountryCode" />
<asp:BoundField DataField="CountryName"
HeaderText="CountryName" />
<asp:BoundField DataField="BaseCurrency"
HeaderText="BaseCurrency" />
<asp:TemplateField HeaderText="CountryRegion">
<EditItemTemplate>
<aspropDownList ID="ddCountryRegion"
runat="server" DataSourceID="odsRegionCol" DataTextField="key"
DataValueField="value">
</aspropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblCountryRegion"
runat="server" Text='<%# Bind("CountryRegion") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="WonCountry"
HeaderText="WonCountry" />
<asp:BoundField DataField="PrimaryIndex"
HeaderText="PrimaryIndex" />
<asp:CommandField ShowEditButton="True" />
</Columns>
<EmptyDataTemplate>
No Country Information has been found.
</EmptyDataTemplate>
</asp:GridView>
Thanks in advance for your help,
Dean