954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

DataGridView being filled by my class...

hey

as the title says, i would like to fill my datagridview from a class i have, this class already gets all the info from my database....

how would i get to fill my DGV...

and another question, how will i change my column header names....

i have this

dgv_Calls.Columns[0].HeaderText = "ID";


but says index out of range, even when changing it to 1.

thanx for the help

phoenix911
Junior Poster
170 posts since May 2009
Reputation Points: 38
Solved Threads: 21
 

should the class that gets the information derive from any other class like IList? or isnt that needed?

phoenix911
Junior Poster
170 posts since May 2009
Reputation Points: 38
Solved Threads: 21
 

lol our only prob was, our database was empty... code will be pasted shortly

phoenix911
Junior Poster
170 posts since May 2009
Reputation Points: 38
Solved Threads: 21
 

o and there was a bit of code missing :)

phoenix911
Junior Poster
170 posts since May 2009
Reputation Points: 38
Solved Threads: 21
 

Well the empty database was not the initial problem. This solved it:

protected void Page_Load(object sender, EventArgs e)
    {
        //DATA GRID VIEW FILL
        clsUploadCallArray getallcalls = new clsUploadCallArray(emp.E_mobile.ToString());
        int c = getallcalls.UploadCallsObj.Count;
        DataSet uploadDS = getallcalls.UplCallDS;
        DataTable uploadDT = uploadDS.Tables["Upload"];
        dgv_Calls.DataSource = uploadDT;
        dgv_Calls.DataBind(); //this was most crucial line
        dgv_Calls.Visible = true;
}


NOTE: I'm still working on the

dgv_Calls.Columns[0].HeaderText = "ID";

part...Cause it still gives an non-negative number error.

phoenix_dwarf
Junior Poster in Training
57 posts since May 2009
Reputation Points: 11
Solved Threads: 0
 

Right, sorted. Here is the solution for the column user specified columns in the datagrid view!

dgv_Calls.HeaderRow.Cells[0].Text = "ID";
            dgv_Calls.HeaderRow.Cells[1].Text = "Tel";


I hope that this will help some of you out there!

phoenix_dwarf
Junior Poster in Training
57 posts since May 2009
Reputation Points: 11
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: