Sunday, 11 November 2012

How TO Find Control IN Grid Cell and Footter

 Master Page:--

    Footer:-
        GridView grv = Master.FindControl("ContentPlaceHolder2").FindControl("GridView1") as GridView;
            TextBox txtCopies = (TextBox)grv.FooterRow.FindControl("txtST");
            TextBox txtDescription = (TextBox)grv.FooterRow.FindControl("txtET");

      Cell:-
        GridView grv = Master.FindControl("ContentPlaceHolder2").FindControl("GridView1") as GridView;
        TextBox txt = (TextBox)grv.Rows[e.RowIndex].FindControl("TextBox1");
        TextBox txt2 = (TextBox)grv.Rows[e.RowIndex].FindControl("TextBox2"); 



Non   Master Page(Simple Page):--
         Cell :----

        int id  =Convert.ToInt16( GridView1.DataKeys[e.RowIndex].Values["Recid"].ToString());
        TextBox txt = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1");
        TextBox txt2 = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox2");



         Footer :-

            TextBox txt = (TextBox)GridView1.FooterRow.FindControl("txtST");
            TextBox txt1 = (TextBox)GridView1.FooterRow.FindControl("txtET");
             intitable();
             dttrip.Rows[0]["TripStart"] = txt.Text;
             dttrip.Rows[0]["TripEnd"] = txt1.Text;

          .......................................
       public void intitable()
            {
         try
          {
             { 
                dttrip.Columns.Add("Recid");
                dttrip.Columns.Add("TripStart");
                dttrip.Columns.Add("TripEnd");
            }
                dttrip.Rows.Add(dttrip.NewRow());

            }
                catch (Exception ex)
            {

                  }
              }

No comments:

Post a Comment