Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. set gridview cell text null

set gridview cell text null

Scheduled Pinned Locked Moved ASP.NET
databasequestionannouncement
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    uspatel
    wrote on last edited by
    #1

    hi when click on edit button,I allow to update 2 columns.I want cell text of these colums should be null means user insert a new value. how it is possible? I used on editing event

    protected void jgjgj(object sender, GridViewEditEventArgs e)
    {
    int index = e.NewEditIndex;
    GridViewRow row=GridView4.Rows[index];

        //((TextBox)row.Cells\[5\].Controls\[0\]).Text = null;
    
    
        row.Cells\[4\].Text = "";
        row.Cells\[5\].Text = "";
       //GridViewRow row=gr
       
       this.Modalpopupextender1.Show();
    }
    

    but it is not working.

    K J 2 Replies Last reply
    0
    • U uspatel

      hi when click on edit button,I allow to update 2 columns.I want cell text of these colums should be null means user insert a new value. how it is possible? I used on editing event

      protected void jgjgj(object sender, GridViewEditEventArgs e)
      {
      int index = e.NewEditIndex;
      GridViewRow row=GridView4.Rows[index];

          //((TextBox)row.Cells\[5\].Controls\[0\]).Text = null;
      
      
          row.Cells\[4\].Text = "";
          row.Cells\[5\].Text = "";
         //GridViewRow row=gr
         
         this.Modalpopupextender1.Show();
      }
      

      but it is not working.

      K Offline
      K Offline
      Karthik Harve
      wrote on last edited by
      #2

      Once you assign new edit index, you have to bind the grid again. then later access the controls and assign the values to that. check this..

      GridView4.EditIndex = e.NewEditIndex;
      GridView4.Datasource = yourDataSource;
      GridView4.DataBind();

      GridViewRow row = GridView4.Rows[4];

      //IF the EditTemplate Contain textboxes..

      TextBox txt = (TextBox)(row.FindControl("TextBoxID"));
      txt.Text="";
      txt = (TextBox)(row.FindControl("TextBoxID2"));
      txt.Text="";

      with regards Karthik Harve

      U 1 Reply Last reply
      0
      • K Karthik Harve

        Once you assign new edit index, you have to bind the grid again. then later access the controls and assign the values to that. check this..

        GridView4.EditIndex = e.NewEditIndex;
        GridView4.Datasource = yourDataSource;
        GridView4.DataBind();

        GridViewRow row = GridView4.Rows[4];

        //IF the EditTemplate Contain textboxes..

        TextBox txt = (TextBox)(row.FindControl("TextBoxID"));
        txt.Text="";
        txt = (TextBox)(row.FindControl("TextBoxID2"));
        txt.Text="";

        with regards Karthik Harve

        U Offline
        U Offline
        uspatel
        wrote on last edited by
        #3

        I do not have textbox control.where to find TextBoxID?

        1 Reply Last reply
        0
        • U uspatel

          hi when click on edit button,I allow to update 2 columns.I want cell text of these colums should be null means user insert a new value. how it is possible? I used on editing event

          protected void jgjgj(object sender, GridViewEditEventArgs e)
          {
          int index = e.NewEditIndex;
          GridViewRow row=GridView4.Rows[index];

              //((TextBox)row.Cells\[5\].Controls\[0\]).Text = null;
          
          
              row.Cells\[4\].Text = "";
              row.Cells\[5\].Text = "";
             //GridViewRow row=gr
             
             this.Modalpopupextender1.Show();
          }
          

          but it is not working.

          J Offline
          J Offline
          Jitendra Parida Jeetu
          wrote on last edited by
          #4

          Try to this one:

          GridView4.EditIndex = e.NewEditIndex;
          string str = GridView4.DataKeys[e.NewEditIndex].Value.ToString();
          GridViewRow row = (GridViewRow)grvCompType.Rows[e.NewEditIndex];
          row.Cells[1].Text = "";

          U 1 Reply Last reply
          0
          • J Jitendra Parida Jeetu

            Try to this one:

            GridView4.EditIndex = e.NewEditIndex;
            string str = GridView4.DataKeys[e.NewEditIndex].Value.ToString();
            GridViewRow row = (GridViewRow)grvCompType.Rows[e.NewEditIndex];
            row.Cells[1].Text = "";

            U Offline
            U Offline
            uspatel
            wrote on last edited by
            #5

            this is same as my efforts.see question again.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups