Solved

Gridview Update via SQLDATASOURCE using Control parameters not working.

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

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…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

772 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