[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Need to update data from dropdown list in DetailsView

Posted on 2007-11-26
4
Medium Priority
?
726 Views
Last Modified: 2008-02-01
I have a DetailsView with a dropdown list. When I select a value from the ddl, the value I selected won't update to the stored procedure. The sproc works fine and I can update other fields. It's just the ddl that won't send the selected value to the sproc.

The below snippet shows the abbreviated code. Thanks.
<asp:DetailsView ID="dvStores" runat="server" AutoGenerateRows="False" BackColor="LightGoldenrodYellow"
	BorderColor="Tan" BorderWidth="1px" CellPadding="2" DataSourceID="GetStoreDetail" ForeColor="Black"
	GridLines="None" Height="50px" CssClass="normal" Width="210px">
 
<asp:TemplateField HeaderText="State" SortExpression="StateLong">
			<EditItemTemplate>
				<asp:DropDownList ID="ddlState" runat="server" DataSourceID="GetStateListShort" DataTextField="StateLong"
					DataValueField="StateId" SelectedValue='<%# Eval("StateID") %>'>
				</asp:DropDownList>
			</EditItemTemplate>
			<InsertItemTemplate>
				<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("StateLong") %>'></asp:TextBox>
			</InsertItemTemplate>
			<ItemTemplate>
				<asp:Label ID="Label1" runat="server" Text='<%# Bind("StateLong") %>'></asp:Label>
			</ItemTemplate>
		</asp:TemplateField>
 
</asp:DetailsView>
 
 
 
 
<asp:SqlDataSource ID="GetStoreDetail" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>"
	SelectCommand="KScoop_GetStoreDetail" SelectCommandType="StoredProcedure" UpdateCommand="KScoop_UpdateStore" UpdateCommandType="StoredProcedure">
	<SelectParameters>
		<asp:ControlParameter ControlID="grdStores" DefaultValue="-1" Name="StoreId" PropertyName="SelectedValue"
			Type="Int16" Size="1" />
	</SelectParameters>
	
	<UpdateParameters>
		
		
		<asp:ControlParameter  ControlID="grdStores"  Name="StateId" PropertyName="SelectedValue"   Type="Int16" />
		
 
	</UpdateParameters>
</asp:SqlDataSource>

Open in new window

0
Comment
Question by:barnesco
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:Oliver Amaya
ID: 20350653
Hi, shouldn't the Name property point to ddlStates?
<UpdateParameters>
  <asp:ControlParameter  ControlID="ddlStates"  Name="StateId" PropertyName="SelectedValue"   Type="Int16" />
</UpdateParameters>

Open in new window

0
 

Author Comment

by:barnesco
ID: 20351415
That's what I thought, too. But when I did, I received an error: Cannot insert a NULL value.
0
 
LVL 10

Accepted Solution

by:
Oliver Amaya earned 2000 total points
ID: 20351478
How about if you add the following code in your page_load event (I'm assuming you're using c#):
GetStoreDetail.UpdateParameters["StateId"].ControlID = ((DropDownList)dvStores.FindControl("ddlState")).ClientID;

Open in new window

0
 

Author Comment

by:barnesco
ID: 20355389
I found the answer: I need to insert the DataKeyNames="StoreID" in the DetailsView.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question