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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. DataGrid in ASP.NET App Using C#

DataGrid in ASP.NET App Using C#

Scheduled Pinned Locked Moved C#
csharpcssasp-netdatabasedebugging
1 Posts 1 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.
  • K Offline
    K Offline
    kayos592
    wrote on last edited by
    #1

    Im having problems updating my grid. The grid loads fine, the edit button functions fine(bringing up textboxes)...I update the data....click "Update" and it reloads the grid. I think this is caused because my form load reloads the grid again but I can't seem to get my grid to show unless I do this. Attached is my form load and update statement....(ps. it enters my update function but the text value is the pre-updated value) public void Page_Load(Object sender, EventArgs e) { _sqlStmt = "SELECT Nm as [Name], OfficeNm as [Office Name], HomePhone as Home, OfficePhone as Office, Address FROM contacts"; oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\\db.mdb"; oleDbDataAdapter1.SelectCommand.CommandText = _sqlStmt; dataSet1.Clear(); oleDbDataAdapter1.Fill(dataSet1, "Contacts"); BindGrid(); } void BindGrid() { Trace.Write ("**IN_BindGrid"); MyDataGrid.DataSource = dataSet1.Tables["Contacts"].DefaultView; MyDataGrid.DataBind(); } public void MyDataGrid_Update(Object sender, DataGridCommandEventArgs e) { Trace.Write ("**In_MyDataGrid_Update"); // For bound columns the edited value is stored in a textbox, // and the textbox is the 0th element in the column's cell string Name = ((TextBox)e.Item.Cells[1].Controls[0]).Text; string OfficeNm = ((TextBox)e.Item.Cells[2].Controls[0]).Text; string Home = ((TextBox)e.Item.Cells[3].Controls[0]).Text; string Office = ((TextBox)e.Item.Cells[4].Controls[0]).Text; string Address = ((TextBox)e.Item.Cells[5].Controls[0]).Text; // Perform the update. //sqlDataAdapter1.Update(ds); oleDbDataAdapter1.Update(dataSet1); // Reload the grid. BindGrid(); } Any help is greatly appreciated.... -Kay -- modified at 23:13 Saturday 6th May, 2006

    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