Ammar Bayg
Ammar Bayg

Reputation: 105

Editing a programatically created datatable asp.net webforms

Good day guys, I am binding asp.net gridview whose datasource table is a programatically created table which gets populated dynamically by getting data from different tables via joins, I want to edit it, how come I am going to get row index(for editing) as data is coming from different tables And has no unique identifier as it is just in memory i.e. dataset visualiser, neither hidden field nor datakeynames seems to work, any help please?

Upvotes: 2

Views: 970

Answers (1)

kgzdev
kgzdev

Reputation: 2885

DataTable GetTableWithUniqueColumn()
        {
            DataTable table = new DataTable();
            table = GetDataFromDB(); //  dynamically getting data from different tables via joins
            table.Columns.Add("UniqueColumn", typeof(Guid));
            foreach (DataRow row in table.Rows)
            {
                row["UniqueColumn"] = Guid.NewGuid();
            }

            return table;
        }

Upvotes: 2

Related Questions