开发者

what does datagrid.columns[number] returns?

开发者 https://www.devze.com 2023-01-08 17:39 出处:网络
I am binding the data in a data table from two different datagrid protected ICollection BindGenerateReport()

I am binding the data in a data table from two different datagrid

protected ICollection BindGenerateReport()
    {
        DataTable dtGenerateReport = new DataTable();
        DataRow drRow;
        for (int innerCounter = 0; innerCounter < dgInvoices.Columns.Count; innerCounter++)
        {
            dtGenerateReport.Columns.Add();
        }
        for (int counter = 0; counter < dgInvoices.Items.Count+dgReceipts.Items.Count;counter++ )
        {
            drRow = dtGenerateReport.NewRow();
            if (dgReceipts.Columns[6] == dgInvoices.Columns[1])
       开发者_Go百科     {
                for (int innerCounter = 0; innerCounter < dgReceipts.Columns.Count; innerCounter++)
                {
                    drRow[innerCounter] = dgReceipts.Columns[innerCounter];
                }
            }
            else
            {
                for (int innerCounter = 0; innerCounter < dgInvoices.Columns.Count; innerCounter++)
                {
                    drRow[innerCounter] = dgInvoices.Columns[innerCounter];
                }
            }
           dtGenerateReport.Rows.Add(drRow);
        }

        DataView dv = new DataView(dtGenerateReport);
        return dv;
    }

and i am binind the function a event click like that

 protected void btnGenerateReport_Click(object sender, EventArgs e)
    {

        dgGenerateReport.DataSource = BindGenerateReport();
        dgGenerateReport.DataBind();
    }

but i want to know that what exactlu datagrid.columns[number] returns (the value inside that column or the datatype or only the column collection ).My code is not working


The columns collection will return an instance of a type derived from DataGridColumn, this could be a BoundColumn, ButtonColumn etc.

Check the MSDN Article for more information.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号