anjali khan

anjali khan

  • NA
  • 293
  • 65.7k

how to click on cell in a grid view using java script ?

Aug 3 2015 12:47 AM

how to click on cell in a grid view using java script ?

i alreday display the data ...now i want if i click on any cell so it is should be editable and update it

idesign page ///

<div style="text-align:center">
      <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns = "false" OnRowDataBound = "OnRowDataBound"
        BackColor="Gray" AlternatingRowStyle-BackColor="Silver" Width="100%">

     </asp:GridView>
    </div>


code////

     protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {

                BoundField bfield = new BoundField();
                bfield.HeaderText = "Name";
                bfield.DataField = "Name";

                GridView1.Columns.Add(bfield);

                TemplateField tfield = new TemplateField();
                tfield.HeaderText = "City";
                GridView1.Columns.Add(tfield);

                tfield = new TemplateField();
                tfield.HeaderText = "View";

                GridView1.Columns.Add(tfield);
            }

            this.BindGrid();
        }
        private void BindGrid()
        {

            DataTable dt = new DataTable();

            dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),new
                DataColumn("Name", typeof(string)),new DataColumn("City",typeof(string))});

            dt.Rows.Add(1, "Anusha", "Bangalore");
            dt.Rows.Add(2, "Sunny", "Chennai");
            dt.Rows.Add(3, "Monika", "Bangalore");
            dt.Rows.Add(4, "Jyoti", "Chennai");
            dt.Rows.Add(5, "Radhika", "Jabalpur");
            dt.Rows.Add(6, "Imran", "Jammu");
           
            dt.Rows.Add(10, "Rutela Singh", "Mumbai");

            GridView1.DataSource = dt;
            GridView1.DataBind();
        }


Answers (1)