You must Sign In to post a response.
  • Category: .NET

    How to create editable gridview in asp.net

    i have one dropdownlist in run time. i want to edit that dropdownlist.

    In run mode as follows

    Corusename Dropdownlist (AFF)

    In dropdownlist aff is there i want to edit that AFF value


    for that how can i do in asp.net using c#.
  • #761478
    Hello Rao,

    You can use the the update query on some button event in gridview to update the data by fetching the id of row and other information.

    Regards,
    Dhiraj C. Solanki

  • #761495
    Hi,

    Use OnRowCommand Event of gridview and pass CommandName and CommandArgument properties for link button and using those properties you can achieve your goal.

    Refer below sample

    <asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" OnRowCommand="gv_OnRowCommand"> <Columns> <asp:TemplateField HeaderText="Edit" > <ItemTemplate> <asp:LinkButton ID="lnkEdit" runat="server" Text='Edit' CommandName="Edit" CommandArgument='<%#Eval("Id")%>' />
    </ItemTemplate> </asp:TemplateField>
    </Columns>
    </asp:GridView>


    and In Code Behind onRowcommand event of gridview do whatever you want.


    protected void gv_OnRowCommand(object sender, GridViewCommandEventArgs e)
    {
    if(e.CommandName=="Edit")
    {
    //perform your action on here
    }
    }


    Hope this will helpful to you...

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #762564
    Hi

    Make auto generate edit button to true.
    And handle the event onRowEditing. Place your code in this event to edit.
    The rows will automatically changes to textboxes in order to make edit your values.

    Regards

    Sai Krishna Reddy.


Sign In to post your comments