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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Editable datagridview

Editable datagridview

Scheduled Pinned Locked Moved C#
csharpcssasp-nethelptutorial
6 Posts 3 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
    saqib82
    wrote on last edited by
    #1

    Hello I need help in editing a datagridview's row. I have a grid which is dynamically populated in a way that user adds some data in the form of rows. Now, I want to give the user the option to edit the row as well. I want to provide the functionality just like asp.net's editable gridview. that is, i want that when a user click on a cell to edit it, a dropdown should be displayed containing selected values. I also want that user may have a cell with text 'edit' and user should click that to start editing the row. as soon as the user click the 'edit', the text should be changed to 'update'. Please guide me for it.

    saq!b "Our scientific power has outrun our spiritual power. We have guided missiles and misguided men." Dr. Martin Luther King Jr.

    D M 2 Replies Last reply
    0
    • S saqib82

      Hello I need help in editing a datagridview's row. I have a grid which is dynamically populated in a way that user adds some data in the form of rows. Now, I want to give the user the option to edit the row as well. I want to provide the functionality just like asp.net's editable gridview. that is, i want that when a user click on a cell to edit it, a dropdown should be displayed containing selected values. I also want that user may have a cell with text 'edit' and user should click that to start editing the row. as soon as the user click the 'edit', the text should be changed to 'update'. Please guide me for it.

      saq!b "Our scientific power has outrun our spiritual power. We have guided missiles and misguided men." Dr. Martin Luther King Jr.

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      Look into DataGridViewComboBoxColumn and DataGridViewButton column. That must suite your needs. :)

      S 1 Reply Last reply
      0
      • D dan sh

        Look into DataGridViewComboBoxColumn and DataGridViewButton column. That must suite your needs. :)

        S Offline
        S Offline
        saqib82
        wrote on last edited by
        #3

        thanks danish. i was just looking into DataGridViewComboBoxColumn. please tell me if it is possible to change the column type of a row at runtime?

        saq!b "Our scientific power has outrun our spiritual power. We have guided missiles and misguided men." Dr. Martin Luther King Jr.

        D 1 Reply Last reply
        0
        • S saqib82

          thanks danish. i was just looking into DataGridViewComboBoxColumn. please tell me if it is possible to change the column type of a row at runtime?

          saq!b "Our scientific power has outrun our spiritual power. We have guided missiles and misguided men." Dr. Martin Luther King Jr.

          D Offline
          D Offline
          dan sh
          wrote on last edited by
          #4

          Set the DisplayStyle property to nothing for the combobox column. HTH.

          S 1 Reply Last reply
          0
          • D dan sh

            Set the DisplayStyle property to nothing for the combobox column. HTH.

            S Offline
            S Offline
            saqib82
            wrote on last edited by
            #5

            can you write the syntax here plz?

            saq!b "Our scientific power has outrun our spiritual power. We have guided missiles and misguided men." Dr. Martin Luther King Jr.

            1 Reply Last reply
            0
            • S saqib82

              Hello I need help in editing a datagridview's row. I have a grid which is dynamically populated in a way that user adds some data in the form of rows. Now, I want to give the user the option to edit the row as well. I want to provide the functionality just like asp.net's editable gridview. that is, i want that when a user click on a cell to edit it, a dropdown should be displayed containing selected values. I also want that user may have a cell with text 'edit' and user should click that to start editing the row. as soon as the user click the 'edit', the text should be changed to 'update'. Please guide me for it.

              saq!b "Our scientific power has outrun our spiritual power. We have guided missiles and misguided men." Dr. Martin Luther King Jr.

              M Offline
              M Offline
              Mada Naga Sankar
              wrote on last edited by
              #6

              Hi, Go through this code........ <asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" ForeColor="Black" Height="285px" onrowcancelingedit="gv_RowCancelingEdit" onrowdeleting="gv_RowDeleting" onrowediting="gv_RowEditing" onrowupdating="gv_RowUpdating" Width="493px"> <FooterStyle BackColor="#CCCCCC" /> <RowStyle BackColor="White" /> <Columns> <asp:BoundField DataField="Name" HeaderText="Item Name" /> asp:TemplateField <HeaderTemplate> <asp:Label ID="lblHead" runat="server" Text="Price"></asp:Label> </HeaderTemplate> <ItemTemplate> <asp:Label ID="lblPrice" runat="server" Text='<%#Eval("Price")%>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:DropDownList ID="ddl1" runat="server"> asp:ListItem1000</asp:ListItem> asp:ListItem2000</asp:ListItem> asp:ListItem3000</asp:ListItem> asp:ListItem4000</asp:ListItem> </asp:DropDownList> </EditItemTemplate> </asp:TemplateField> <asp:ButtonField DataTextField="Description" HeaderText="Desription" /> <asp:CommandField ShowCancelButton="true" ShowDeleteButton="true" ShowEditButton="true" /> </Columns> <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" /> <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" /> </asp:GridView>

              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