1

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

2
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by phoenix_dwarf
0

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

0

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.

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!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.