Solved

Gridview Update via SQLDATASOURCE using Control parameters not working.

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Web page design problem 3 41
Send parameters via datatable ajax call 4 47
vb.net dbnull syntax 1 59
Using asp.net to develop android, ios, windows APPS 7 55
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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 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