Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Gridview Update via SQLDATASOURCE using Control parameters not working.

Posted on 2010-11-30
3
Medium Priority
?
995 Views
Last Modified: 2012-05-10
Hi,

I am using Visual Studio 2010 asp.net 4.0 and cannot seem to update my databse when i use sqldatasource update.  For example.  All I need to do is upadate two fileds with the current logged on user and change the status from New to Active.  The current logged on user is grabbed via label using HttpContext.Current.User.Identity.Name.ToString().  And the "Active" status is a default value in the update parameter sqldatasource. My code is below.
-------------------------------------------------------------------------------------------------------------------
                         <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                            DataKeyNames="ticketID" DataSourceID="SqlDataSource1">
                            <Columns>
                                <asp:BoundField DataField="ticketID" HeaderText="ticketID"
                                    InsertVisible="False" ReadOnly="True" SortExpression="ticketID" />
                                <asp:BoundField DataField="Status" HeaderText="Status"
                                    SortExpression="Status" />
                                <asp:BoundField DataField="AssignedTo" HeaderText="AssignedTo"
                                    SortExpression="AssignedTo" />
                            </Columns>
                        </asp:GridView>
                        <br />
                        <br />
                        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                            ConnectionString="<%$ ConnectionStrings:mmchd_dbConnectionString %>"
                           
                            SelectCommand="SELECT [ticketID], [Status], [AssignedTo] FROM [Tickets_tbl]"
                            UpdateCommand="UPDATE [Tickets_tbl] SET [Status] = @Status, [AssignedTo] = @AssignedTo WHERE [ticketID] = @ticketID">

                            <UpdateParameters>
                                <asp:Parameter DefaultValue="" Name="ticketID" Type="Int32" />
                                <asp:Parameter DefaultValue="Active" Name="Status" />
                                <asp:ControlParameter ControlID="lblName" DefaultValue="" Name="AssignedTo"
                                    PropertyName="Text" />
                            </UpdateParameters>
                        </asp:SqlDataSource>
----------------------------------------------------------------------------------------------------------------

I can update the table manually by typing in the values in the edit mode of the gridview, but it seems that it cannot grab those values dynamically for some reason.  I

Thanks for any help!!
0
Comment
Question by:kouts1
[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
3 Comments
 
LVL 18

Assisted Solution

by:carlnorrbom
carlnorrbom earned 2000 total points
ID: 34246685
Hi,


I don't see the label with ID="lblName" anywhere in the markup code posted, I assume it sits outside the gridview? Does any of the values propagate into the database on update?

/Carl.
0
 

Accepted Solution

by:
kouts1 earned 0 total points
ID: 34251137
yes the label is outside the gridview.  No values change during the update event.  
0
 

Author Closing Comment

by:kouts1
ID: 34328732
solved
0

Featured Post

Technology Partners: 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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

730 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