Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Wednesday, 4 February 2015

Introduction
In Asp.Net we sometimes require to find TextBox, DropDownList or other controls placed inside GridView so that we can get their value and update if needed.In this article i have tried to explain how to  find TextBox, DropDownList or other controls in GridView in asp.net


Suppose you have a GridView grdEmp  and you want to find a control e.g TextBox or DropDownList placed inside the GridView on RowUpdating event then here is the code:

<asp:GridView ID="grdEmp" runat="server" >
</GridView>

C#.Net Code to find TextBox, DropDownList or other controls in Gridview in asp.net


protected void grdEmp_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        DropDownList ddlDept = (DropDownList)grdEmp.Rows[e.RowIndex].FindControl("ddlGrdDept");

        TextBox txtcity = (TextBox)grdEmp.Rows[e.RowIndex].FindControl("txtCity");
    }


VB.Net Code to find TextBox, DropDownList or other controls in Gridview in asp.net
Protected Sub grdEmp_RowUpdating(sender As Object, e As GridViewUpdateEventArgs)

0 comments:

Post a Comment