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. paging

paging

Scheduled Pinned Locked Moved ASP.NET
3 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.
  • R Offline
    R Offline
    ravikiranreddydharmannagari
    wrote on last edited by
    #1

    System.Data.DuplicateNameException: A column named 'rating' already belongs to this DataTable. at System.Data.DataColumnCollection.RegisterName(String name, Object obj) my code iam getting above exception DataTable dt=new DataTable(); try { foreach(DataGridItem dg in DataGrid1.Items) { String Name = dg.Cells[0].Text; DataRow dr; DataColumn dc; dc=new DataColumn("rating"); dt.Columns.Add(dc); dr=dt.NewRow(); dr[0]=Name; dt.Rows.Add(dr); DataGrid2.DataSource=dt; DataGrid2.DataBind(); } } catch(Exception ex) { Response.Write(ex.ToString()); } finally { conn.Close(); }

    G S 2 Replies Last reply
    0
    • R ravikiranreddydharmannagari

      System.Data.DuplicateNameException: A column named 'rating' already belongs to this DataTable. at System.Data.DataColumnCollection.RegisterName(String name, Object obj) my code iam getting above exception DataTable dt=new DataTable(); try { foreach(DataGridItem dg in DataGrid1.Items) { String Name = dg.Cells[0].Text; DataRow dr; DataColumn dc; dc=new DataColumn("rating"); dt.Columns.Add(dc); dr=dt.NewRow(); dr[0]=Name; dt.Rows.Add(dr); DataGrid2.DataSource=dt; DataGrid2.DataBind(); } } catch(Exception ex) { Response.Write(ex.ToString()); } finally { conn.Close(); }

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      That is because you are trying to add more than one column with the same name. What is it that you are trying to do?

      --- b { font-weight: normal; }

      1 Reply Last reply
      0
      • R ravikiranreddydharmannagari

        System.Data.DuplicateNameException: A column named 'rating' already belongs to this DataTable. at System.Data.DataColumnCollection.RegisterName(String name, Object obj) my code iam getting above exception DataTable dt=new DataTable(); try { foreach(DataGridItem dg in DataGrid1.Items) { String Name = dg.Cells[0].Text; DataRow dr; DataColumn dc; dc=new DataColumn("rating"); dt.Columns.Add(dc); dr=dt.NewRow(); dr[0]=Name; dt.Rows.Add(dr); DataGrid2.DataSource=dt; DataGrid2.DataBind(); } } catch(Exception ex) { Response.Write(ex.ToString()); } finally { conn.Close(); }

        S Offline
        S Offline
        sam L 0
        wrote on last edited by
        #3

        As Guffy said, a column named 'rating' is already part of your DataTable, and then in your code dc=new DataColumn("rating"); dt.Columns.Add(dc); You are adding the same column again to the data table, ofcourse it'll complain. Good luck sam

        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