Solved

Gridview Update via SQLDATASOURCE using Control parameters not working.

Posted on 2010-11-30
3
974 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
  • 2
3 Comments
 
LVL 18

Assisted Solution

by:carlnorrbom
carlnorrbom earned 500 total points
Comment Utility
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
Comment Utility
yes the label is outside the gridview.  No values change during the update event.  
0
 

Author Closing Comment

by:kouts1
Comment Utility
solved
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now