Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing dropdownlist value Update parameters in listview

Status
Not open for further replies.

stinkybee

Programmer
May 15, 2001
218
GB
I'm trying to update data from a listview whilst passing the value of a dropdownlist within the edittemplate.

Sample code:

Code:
	<asp:SqlDataSource runat="server" id="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>" 
	SelectCommand="SELECT * FROM [table1]" 
	UpdateCommand="UPDATE [table1] SET [table1.column1] = @ddl_value">
		<UpdateParameters>
			<asp:controlparameter ControlID="dropDownList1" Name="ddl_value" Type="Int32" />
		</UpdateParameters>
	</asp:SqlDataSource>

			
	<asp:SqlDataSource id="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>" 
	SelectCommand="SELECT [table2.column1] FROM [table2]">
	</asp:SqlDataSource>
			
	

	<asp:ListView id="ListView1" runat="server" DataSourceID="SqlDataSource1" >
	...
		<EditItemTemplate>
			<tr style="">
				<td>
				<asp:button id="UpdateButton" runat="server" CommandName="Update" Text="Update" />
				<asp:button id="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
				</td>
				<td>
				<asp:dropDownList runat="server" DataSourceID="SqlDataSource2" id="dropDownList1" 
				DataTextField="column1" DataValueField="column1" SelectedValue='<%# Bind("column1")%>' />
				</td>
			</tr>
		</EditItemTemplate>
	...
	<asp:listview>

The drop down list populates ok when the edit button is clicked in the listview but the following error is generated when clicking the update button

Could not find control 'dropDownList1' in ControlParameter 'ddl_value'

I've Googled the problem for the last few hours with no meaningful results so any help would be gratefully received.
 
Actually the error is:

DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'column1'.

When I have

SelectedValue='<%# Bind("column1")%>'

in the dropdownlist. The error above

Could not find control 'dropDownList1' in ControlParameter 'ddl_value'

is produced when the bind is removed. I have now been trying to find an answer for a few days so any help would be appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top