Skip to content Skip to sidebar Skip to footer

How To Get Value Of Textbox Inside Of Gridview

My GridView has a ContentTemplate containing ItemTemplate. ItemTemplate has textbox and button. Here is a fragment of the code:

Solution 1:

functionValidateEmail(btnObj) {            
      alert(btnObj.id);
      var email = $(btnObj).siblings('input:text').attr('id');
      alert(email);
      returnfalse;
  }

This will return the id of the text input using your JavaScript solution.

Working example using some of your code.

Solution 2:

protectedvoidGridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if(e.Row.RowType == DataControlRowType.DataRow)
    {
        TextBox txtEmail= e.Row.FindControl("yourEmailTextBox") as TextBox;
        txtEmaill.AddAtrribute("blur",'ValidateEmail(this)');
    }
}

this should be enough,you can also read this post

Post a Comment for "How To Get Value Of Textbox Inside Of Gridview"