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. datagrid the headache!

datagrid the headache!

Scheduled Pinned Locked Moved ASP.NET
tutorialannouncement
4 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.
  • H Offline
    H Offline
    hakanaktan
    wrote on last edited by
    #1

    Hi, Plz tell me how to access the changed values on a datagrid when user pressed update button. I know the normal way : myTextBox.Text=CType(myGrid.cells(1).Controls(0),TextBox).Text But i have dynamic boundColumns that are created by pageLoad. Searched all forums and googled for 2 days..nothing found.. Thanx in advance.. --junior coder--

    M N H 3 Replies Last reply
    0
    • H hakanaktan

      Hi, Plz tell me how to access the changed values on a datagrid when user pressed update button. I know the normal way : myTextBox.Text=CType(myGrid.cells(1).Controls(0),TextBox).Text But i have dynamic boundColumns that are created by pageLoad. Searched all forums and googled for 2 days..nothing found.. Thanx in advance.. --junior coder--

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, You need to make sure that the dynamic column is in the Columns collection of the datagrid when the page posts back, and more importantly it should be readded before the Page_Load event gets fired:

      private void Page_Load(object sender, System.EventArgs e)
      {
      if(!IsPostBack)
      {
      BoundColumn col = new BoundColumn();
      col.DataField = "CategoryName";
      DataGrid1.Columns.AddAt(1, col);

      	BindGrid();
      }
      

      }

      protected override void LoadViewState(object savedState)
      {
      base.LoadViewState (savedState);

      BoundColumn col = new BoundColumn();
      col.DataField = "CategoryName";
      DataGrid1.Columns.AddAt(1, col);
      

      }

      1 Reply Last reply
      0
      • H hakanaktan

        Hi, Plz tell me how to access the changed values on a datagrid when user pressed update button. I know the normal way : myTextBox.Text=CType(myGrid.cells(1).Controls(0),TextBox).Text But i have dynamic boundColumns that are created by pageLoad. Searched all forums and googled for 2 days..nothing found.. Thanx in advance.. --junior coder--

        N Offline
        N Offline
        nnabuikem
        wrote on last edited by
        #3

        Did u include the ispostback check to ur databinding ? if it's not included, the data might be lost. just b4 ur datasource selection include, If Not IsPostBack then datagrid.datasource=whatever datagrid.bind() .... Nnabuikem MCP - .NET

        1 Reply Last reply
        0
        • H hakanaktan

          Hi, Plz tell me how to access the changed values on a datagrid when user pressed update button. I know the normal way : myTextBox.Text=CType(myGrid.cells(1).Controls(0),TextBox).Text But i have dynamic boundColumns that are created by pageLoad. Searched all forums and googled for 2 days..nothing found.. Thanx in advance.. --junior coder--

          H Offline
          H Offline
          hakanaktan
          wrote on last edited by
          #4

          That was the problem : my columns were lost when page is post back.. I found the way. -I create dynamic textBoxes at pageLoad event . -When user push "Edit" button on template column, i get the values of cells by: CType(Me.FindControl("Form1").FindControl("nameOfControl"), TextBox).Text = CType(e.Item.Cells(counter).Controls(0), TextBox).Text -I add attribute of onblur to these textBoxes to get values of changed datagrid cells. virtualTextBox.Attributes.Add("onblur", "document.getElementById('" + nameOfControl & "').value=this.value") -Then i can use this virtual textBoxes Text properties to update my dataBase: newValue = CType(Me.FindControl("Form1").FindControl(nameOfControl), TextBox).Text() That 's it.. Thanx again for your helps.. --junior coder--

          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