Welcome Guest Search | Active Topics | Sign In | Register

populating grid help needed Options
dllhell
Posted: Monday, February 23, 2009 9:50:30 AM
Rank: Member
Groups: Member

Joined: 2/21/2008
Posts: 25
Hi,

I want to populate Grid with this method:

SqlConnection Conn = new SqlConnection(clsDataProc.GetConnString());
SqlCommand command = new SqlCommand("select * from abc", Conn);
Conn.Open();
Grid1.DataSource = command.ExecuteReader();
Grid1.DataBind();

After execution of this method, grid multiply rows as many as it is in select but no generating any columns.
What I did missed?
eo_support
Posted: Monday, February 23, 2009 11:24:08 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Please read the document first:

http://doc.essentialobjects.com/library/1/grid/start.aspx

Thanks!
phil dude
Posted: Sunday, January 3, 2010 6:54:25 AM
Rank: Newbie
Groups: Member

Joined: 1/3/2010
Posts: 4
Hello!
I am having the same problem. I tried reading the docs but could not understand what I'm missing. Can I please have some assistance?

My C# code to populate grid. In my grid I get the same number of rows that the resultSet returns. The fields just don't get populated. Right now I'm only trying to just get anything shown up. I understand that I need to further define what to put inside the columns but I can't find out how to do this. Any assistance is highly appreciated.

Code: C#
private void UpdateData(int i)
        {
           
            


            createConnection("master");
            mySqlCommand = mySqlConnection.CreateCommand();
            
            string sql = "SELECT * FROM Customer";
            if (Grid1.Columns[0] != null)
                sql = string.Format("{0} {1}", sql, Grid1.Columns[0].OrderByClause);
            mySqlCommand.CommandText = sql;
            Grid1.DataSource = mySqlCommand.ExecuteReader();
            

            Grid1.DataBind();
            closeConnection();
            
  
        }


Grid definition in asp
Code: HTML/ASPX
<Columns>
            <eo:RowNumberColumn>
            </eo:RowNumberColumn>
            <eo:StaticColumn HeaderText="Customer" DataField="" DataType="String">
            </eo:StaticColumn>
            <eo:StaticColumn HeaderText="Address" DataField="" DataType="String">
            </eo:StaticColumn>
            <eo:StaticColumn HeaderText="Week" DataField="" DataType="String">
            </eo:StaticColumn>
        </Columns>


What am I missing?
eo_support
Posted: Sunday, January 3, 2010 7:59:48 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You need to set each column's DataField property.

Thanks
phil dude
Posted: Sunday, January 3, 2010 8:05:37 AM
Rank: Newbie
Groups: Member

Joined: 1/3/2010
Posts: 4
Hi!
Thank you, I tried doing that but in my frustrated attempt I forgot to make sure there were columns in the database that matched the name of the datafield defined. Now it works. May this be of use to anyone with the same problem.

Thank you for your quick reply!
eo_support
Posted: Sunday, January 3, 2010 8:26:55 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
You are welcome. Glad that it is working for you now!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.