Have an application i'm coding at the moment, which uses DataGrid's. What i want to do is replace the header text with that from a column within an sql database.. Has anybody tried this or any idea on how it could be achieved?
What you should do.
Fill a DataTable with data using an sql query(Easy and searchable on Google and Stackoverflow).
Say your query is
Select id, Emp_Name from emp;
Provide that Datatable as ItemSource to DataGrid.
Now your columns of grid will be same as that of your sql query. ie. datagrid will have 2 columns (id and Emp_Name)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.