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

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

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

o and there was a bit of code missing :)

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.

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.