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

  • Home
  • SEARCH
  • 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 8994573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:27:47+00:00 2026-06-15T23:27:47+00:00

I have a grid view with below markup and below datasourse (linq query-stored procedure),

  • 0

I have a grid view with below markup and below datasourse (linq query-stored procedure), I have added delete and update command field, but I do not know what code I have to add until deleting and updating for this grid view works.

<asp:GridView ID="GridViewDocuments_Search" runat="server" AutoGenerateColumns=False Visible="False" onrowcommand="GridViewDocuments_Search_RowCommand"  
  DataKeyNames="DocID" PageSize="100"  >
    <Columns>
    <asp:TemplateField HeaderText = "Details">
           <ItemTemplate>
      <asp:Button ID ="btn_Show" Text="Details" runat= "server" CommandName= "Details" CommandArgument='<%#
        Container.DataItemIndex%>' />
        </ItemTemplate>
            </asp:TemplateField>

        <asp:HyperLinkField  DataNavigateUrlFields="Docid,Transid" 
            DataNavigateUrlFormatString="~/DocResult.aspx?Docid={0}&TransID={1}"
            DataTextField="DocumentNo" HeaderText="Doc" />
        <asp:BoundField DataField="title" HeaderText="Title" SortExpression="title" />
        <asp:BoundField DataField="transmittal" HeaderText="transmittal" SortExpression="transmittal" />
        <asp:BoundField DataField="Docid" HeaderText="Docid" Visible="false" />
        <asp:CommandField ShowEditButton="True" />
        <asp:CommandField ShowDeleteButton="True" />
    </Columns>
</asp:GridView>


protected void btnSearch_Click(object sender, EventArgs e)
{
    _DataContext = new EDMSDataContext();
    var query = _DataContext.spQuickSearch(txtSearchKeywords.Text);
    GridViewDocuments.Visible = false;
    GridViewDocuments_Search.Visible = true;
    GridViewDocuments_Search.DataSource = query;
    GridViewDocuments_Search.DataBind();
}

The stored procedure spQuickSearch is like below:

ALTER proc [dbo].[spQuickSearch]
@Searchtext varchar(50)=null

AS

 select DocId,TransId,DocumentNo,Title,TRANSMITTAL
from DocumentSum2
 where DocumentNo like '%'+@SearchText + '%'
 or Title like '%'+@SearchText + '%'
 or TRANSMITTAL like '%'+@SearchText + '%'
  • 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-06-15T23:27:48+00:00Added an answer on June 15, 2026 at 11:27 pm

    You can handle commands like this:

        protected void GridViewDocuments_Search_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string cmdArg = e.CommandArgument.ToString();
            switch (e.CommandName)
            {
                case "Details":
                    //TODO: handle your Details command...
                    break;
                case "Delete":
                    //TODO: handle your Delete command...
                    break;
            }
        }
    

    You can add as many commands as you want (CommandName property for control). For example you can add another button and set Delete CommandName like this:

     <asp:Button ID ="btn_Delete" Text="Delete" runat= "server" CommandName= "Delete" CommandArgument='<%#
        Container.DataItemIndex%>' />
    

    After command is completed you can call DataBind to refresh grid:

    GridViewDocuments_Search.DataBind();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using vb.net code. I have grid view, please see the code below:
I have a grid view control in my application. Please see the below code.
I have a grid view which contains a button in a template field. I
I have a grid view code below which have divided into 3 column .
I Have a bound Data grid view to the below Questions Class: public class
I have got a button field in my grid view. When I click multiple
I have used below code for delete command of GridView, but when I press
Data source of my grid view comes of stored procedure by using linqdatasource. The
I have a grid view on my page and I want to export it
I have a grid view in my main page and I display some data

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.