Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5844539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:18:26+00:00 2026-05-22T12:18:26+00:00

Hey guys, I have a GridView which is binded to SqlDataSource, everything works fine,

  • 0

Hey guys,
I have a GridView which is binded to SqlDataSource, everything works fine, just update does not works, i am calling stored procedure, and all parameters and its dataTypes are proper, actually none of the events work on that update button, i tried to change the CommandName to “Change” and created OnCommand Event, and wrote Response Message in the code. but nothing happens on the update button, cancel button works fine, and also delete works, there is just a problem with update, even if the procedure has some issue atleast event should raised, i even checked in Sql Profiler, but the update procedure never hits Sql Server 2008…

But when i remove SqlDataSource then everything works fine also the update command with same stored procedure.

Please help me out for this, i have stuck here badly

<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" 
    CellPadding="4" DataKeyNames="Title" EnableModelValidation="True"
    ForeColor="#333333" GridLines="None"
    ShowFooter="True" Width="950" AllowPaging="true" PageSize="10">
    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    <Columns>
        <asp:TemplateField HeaderText="Title">
            <ItemTemplate>
                <%# Eval("Title") %>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:Label ID="txtEditTitle" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
            </EditItemTemplate>
         </asp:TemplateField>
        <asp:TemplateField HeaderText="Quote">
            <ItemTemplate>
                <%# Eval("Quote") %>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="txtEditQuote" runat="server" Text='<%# Bind("Quote") %>'></asp:TextBox>
            </EditItemTemplate>
        </asp:TemplateField >
        <asp:TemplateField HeaderText="Quote Link">
            <ItemTemplate>
                <%# Eval("QuoteLink") %>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="txtEditQuoteLink" runat="server" Text='<%# Bind("QuoteLink") %>'></asp:TextBox>
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Published">
            <ItemTemplate>
                <asp:CheckBox ID="chkBox" runat="server" Checked='<%# Convert.ToBoolean(Eval("Published")) %>' Enabled = "false" />  
            </ItemTemplate>
            <EditItemTemplate>
                <asp:CheckBox ID="chkEditBox" runat="server" Checked='<%# Bind("Published") %>' Enabled="true" />
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="PublishedDate">
            <ItemTemplate>
                <%# Convert.ToDateTime(DataBinder.Eval(Container.DataItem,"PublishedDate")).ToString("MM.dd.yyyy") %>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="txtEditPublishedDate" runat="server" Text='<%# Bind("PublishedDate") %>'></asp:TextBox>
            </EditItemTemplate>
        </asp:TemplateField>
       <asp:TemplateField HeaderText="Commands">
            <ItemTemplate>
                <asp:ImageButton runat="server" ID="Edit" ImageUrl="/images/edit.gif" CommandName="Edit" />
                <asp:ImageButton runat="server" ID="Delete" ImageUrl="/images/delete.gif" CommandName="Delete" />
            </ItemTemplate>
            <EditItemTemplate>
                <asp:Button runat="server" ID="btn1" CommandName="Update" Text="Update" />
                <asp:ImageButton runat="server" ID="Cancel" ImageUrl="/images/delete.gif" CommandName="Cancel" />
            </EditItemTemplate>
        </asp:TemplateField>
    </Columns>
    <EditRowStyle BackColor="#999999" />
    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" HorizontalAlign="Left" ForeColor="White" />
    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>
  <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>" 
    DeleteCommand="DELETE FROM [Quotes] WHERE [Title] = @Title"
    SelectCommand= "SELECT [Title], [Quote], [QuoteLink], [Published], [PublishedDate] FROM [Quotes]" 
    UpdateCommand="sp_UpdateQuotes" UpdateCommandType="StoredProcedure"
    InsertCommand="INSERT INTO [Quotes] ([Title], [Quote], [QuoteLink], [Published], [PublishedDate]) VALUES (@Title, @Quote, @QuoteLink, @Published, @PublishedDate)">
    <DeleteParameters>
        <asp:Parameter Name="Title" Type="String" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="Title" Type="String" />
        <asp:Parameter Name="Quote" Type="String" />
        <asp:Parameter Name="QuoteLink" Type="String" />
        <asp:Parameter Name="Published" Type="Boolean" />
        <asp:Parameter Name="PublishedDate" Type="DateTime" />
    </InsertParameters>
    <UpdateParameters>
        <asp:Parameter Name="Quote" Type="String" DefaultValue = "QUotes are simple" />
        <asp:Parameter Name="QuoteLink" Type="String" DefaultValue = "QUotes are Linked" />
        <asp:Parameter Name="Published" Type="Boolean" DefaultValue = "False" />
        <asp:Parameter Name="PublishedDate" Type="DateTime" DefaultValue = "05/15/2011" />
    </UpdateParameters>
</asp:SqlDataSource>


ALTER PROCEDURE [dbo].[sp_UpdateQuotes]
@Title varchar(max),
@Quote varchar(max),
@QuoteLink varchar(max),
@Published bit,
@PublishedDate DateTime
AS
BEGIN
UPDATE dbo.Quotes SET
Quote = @Quote,
QuoteLink = @QuoteLink,
Published = @Published,
PublishedDate = @PublishedDate

WHERE Title = @Title  

If @Published = 1  
BEGIN  
    UPDATE dbo.Quotes SET Published = 0 WHERE Title <> @Title AND Published = 1  
END  

END

Hope this would give you clear idea about what is messing me for update

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:18:26+00:00Added an answer on May 22, 2026 at 12:18 pm

    You have not passed the @Title parameter, which is your primary Key in your stored procedure and is used in the where Clause.

    If you want to see that there is no Title Parameter in Update Parameters:

    <UpdateParameters>
        <asp:Parameter Name="Quote" Type="String" />
        <asp:Parameter Name="QuoteLink" Type="String" />
        <asp:Parameter Name="Published" Type="Boolean" />
        <asp:Parameter Name="PublishedDate" Type="DateTime" />
    </UpdateParameters>
    

    If you add the Title Parameter, it will work:

        <asp:Parameter Name="Title" Type="String" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey guys, i have a gridview which displays 10records per page, now i want
Hey guys I have the following while loop which seems not to stop. It's
Hey guys, I have created a tree which is not a binary tree. Now,
Hey guys I have a gridview and below it 4 textboxes I'm using to
Hey guys, I have a little button functionality that is not erring, but also
Hey guys I have the following code working which is sending a GET Request
Hey guys, i have a gridview, now i want to make the rows draggable,
Hey guys i have the string: /new/krymson/ currently i have the regex: /\/new\// which
Hey guys i wrote a quick test. I want delete to call deleteMe which
Hey guys, I have an application that I want to display some data from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.