Two different datatables are bound to the same gridview under different conditions. How can I implement this binding?
For example, if I set the binding column datafield = "ID" at the beginning, the first ID able containing the ID column is successfully bound, however, in another case, I want to bind the "name" of another able, but how can I change datafield = "ID" to datafield = "name"?
It seems impossible. The binding in the gridview cannot be changed, but from the database perspective, we can change the table column name as long as we get the alias with the corresponding field, we have solved this problem. We have the same alias for the columns required for different tables.
For example:
Table
Table1
Id S E
0 dfdf DFF
1 Mmm lll
Table 2
Name file Classe
U ppp llll
Llll hhhh KKK
Select ID as D, s as a, e as R from Table1
Select name as D, file as a, Classe as R from Table2
We bind datafield = "D". Select different tables and the preceding two SQL statements as needed. Then we can bind two different tables to a gridview.