update parameter question in detailView?

Posted on 2008-02-07
Medium Priority
Last Modified: 2008-03-06

I have this detailview and i am using a dropdown in the editform.
I also used sqldatasource to update the record by passing the parameter.
Without the dropdown in the editform (all regular textboxes), it gets update fine.

But when I insert the dropdown in the edittemplate, it doesn't get update and no error pops up.
I don't know how to debug this since I don't get any errors when I run it.

As an example, say I have this address table(ID,Name,Address,Type)

I thought I can use fixed parameter and controlparameter.
But it doesn't get updated.

How can I debug this??
Should I stay away from the sqldatasource and use the stored proc or code in code behind page??

<asp:sqldatasource id=sqldatasource1
selectcommand="select id,name,address,type from address where (id=@id)"
updatecommand = "update address set name=@name,address=@address,type=@type where (id=@id)">
<asp:querystringparameters name=id querystringfield=id type=int/>
I thought I can use fixed parameter and controlparameter.
But it doesn't get updated.

Open in new window

Question by:dkim18
  • 2
LVL 12

Accepted Solution

CmdoProg2 earned 1500 total points
ID: 20896545
try this ....
     <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="id"
        DataSourceID="SqlDataSource1" Height="50px" Width="125px">
          <asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
          <asp:BoundField DataField="address" HeaderText="address" SortExpression="address" />
          <asp:BoundField DataField="type" HeaderText="type" SortExpression="type" />
          <asp:CommandField ShowEditButton="True" />
      <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="MyConnString"
        ProviderName="System.Data.SqlClient" SelectCommand="SELECT [id], [name], [address], [type] FROM [testers] WHERE ([id] = @id)"
        UpdateCommand="UPDATE testers SET name = @name, address = @address, type = @type WHERE (id = @id)">
          <asp:Parameter Name="name" />
          <asp:Parameter Name="address" />
          <asp:Parameter Name="type" />
          <asp:Parameter Name="id" />
          <asp:QueryStringParameter Name="id" QueryStringField="id" Type="Int32" />

Open in new window


Author Comment

ID: 20901922
It works fine with default editform like your example.

When I change it to templatefield, it is not updating correctly.

I had three boundfields and one templatefield with dropdownlist.
Nothing happens.

LVL 12

Expert Comment

ID: 20902343
Could you send me the snippet of the detail view?

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
An ASP.NET Web Form User Control is not newly introduced in ASP.NET. In fact, it was an old technology yet still playing a role to generate web content, especially when we want to use it to have a better and easy way to control part of the web conte…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…

601 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