Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Select entire row details on click of button of that row inside a GridView

Select entire row details on click of button of that row inside a GridView

Scheduled Pinned Locked Moved Web Development
csharpquestionasp-netdatabase
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    salon
    wrote on last edited by
    #1

    :zzz: I am displaying a GridView on some specific criteria which is entered by some textboxes say studentid, studentname as input from textbox and show records in GridView. For this I m using a stored procedure which returns a datatable based on inputs came from textboxes. I want an Edit button in the Gridview on click of which a

    with some label and textbox controls get displayed with prefilled entries. For this I want the datarow from the datatable got from the stored procedure, from where I will get the complete info. Also I want to edit the data. How can I get the row details of specified Edit button row and which way is better put a command button control in ItemTemplate of GridView or use a Buttonfield cotnrol inside the GridView? I am working in ASP.NET2.0 and C#. I m not getting the correct way, can anybody suggest me? Thanks in advance,

    R 2 Replies Last reply
    0
    • S salon

      :zzz: I am displaying a GridView on some specific criteria which is entered by some textboxes say studentid, studentname as input from textbox and show records in GridView. For this I m using a stored procedure which returns a datatable based on inputs came from textboxes. I want an Edit button in the Gridview on click of which a

      with some label and textbox controls get displayed with prefilled entries. For this I want the datarow from the datatable got from the stored procedure, from where I will get the complete info. Also I want to edit the data. How can I get the row details of specified Edit button row and which way is better put a command button control in ItemTemplate of GridView or use a Buttonfield cotnrol inside the GridView? I am working in ASP.NET2.0 and C#. I m not getting the correct way, can anybody suggest me? Thanks in advance,

      R Offline
      R Offline
      Rasma Raj
      wrote on last edited by
      #2

      You can edit a particular datagrid row using EditCommand event of the datagrid. i attach code below: private void Edit_DataGrid(object source,System.Web.UI.WebControls.DataGridCommandEventArgs e) { // We use CommandEventArgs e to get the row which is being clicked // This also changes the DataGrid labels into Textboxes so user can edit them myDataGrid.EditItemIndex = e.Item.ItemIndex; // Always bind the data so the datagrid can be displayed. } thankyou Rasma

      1 Reply Last reply
      0
      • S salon

        :zzz: I am displaying a GridView on some specific criteria which is entered by some textboxes say studentid, studentname as input from textbox and show records in GridView. For this I m using a stored procedure which returns a datatable based on inputs came from textboxes. I want an Edit button in the Gridview on click of which a

        with some label and textbox controls get displayed with prefilled entries. For this I want the datarow from the datatable got from the stored procedure, from where I will get the complete info. Also I want to edit the data. How can I get the row details of specified Edit button row and which way is better put a command button control in ItemTemplate of GridView or use a Buttonfield cotnrol inside the GridView? I am working in ASP.NET2.0 and C#. I m not getting the correct way, can anybody suggest me? Thanks in advance,

        R Offline
        R Offline
        Rasma Raj
        wrote on last edited by
        #3

        To use RowDataBound to find Id in each row: In code behind: protected void Page_Load(object sender, EventArgs e) { //Accepting the Id of a clicked row. string id = Convert.ToString(Request.QueryString["id"]); } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string id = e.Row.Cells[0].Text.ToString(); e.Row.Attributes["onclick"] = "window.navigate('samewebpage.aspx?id=" + id + ")"; } } you can access id from page load, reading the entire data of corresponding id using datatable or datareader and display the contents in a textbox or label. Thankyou, Rasma

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups