Solved

Gridview Update via SQLDATASOURCE using Control parameters not working.

Posted on 2010-11-30
3
979 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

867 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

18 Experts available now in Live!

Get 1:1 Help Now