C
C#17mo ago
Silentgamerz

✅ ListView Not Showing real values

I am filling the data from my SqlServer to display it on listview but it is showing system.data.data.rowview here is my code- 'using System.Data; using System.Data.SqlClient; using System.Windows; using System.Windows.Controls; namespace Demo_APP { public partial class ManageStock : Window { DBAccess dBAccess = new DBAccess(); DataTable dt = new DataTable(); public ManageStock() { InitializeComponent(); LoadList(); } public void LoadList() { string query = "select * from DesignTB"; dBAccess.readDatathroughAdapter(query, dt); ListView.ItemsSource = dt.DefaultView; dBAccess.closeConn(); } } }
3 Replies
HimmDawg
HimmDawg17mo ago
Is this WPF? this looks like WPF. The listview is given a view, so you have to tell the listview, what is in there. One sec
<ListView>
<ListView.View>
<GridView>
<GridViewColumn Header="HeaderName" DisplayMemberBinding="{Binding ColumnName}" />
...
</GridView>
</ListView.View>
</ListView>
<ListView>
<ListView.View>
<GridView>
<GridViewColumn Header="HeaderName" DisplayMemberBinding="{Binding ColumnName}" />
...
</GridView>
</ListView.View>
</ListView>
You'll have to create columns in your ListView for each of the columns you are getting from the query
Silentgamerz
SilentgamerzOP17mo ago
Oh ok I had seen a yt video once before and he had done it in this way so I just copied him Yes it's wpf Thank you I will try doing this
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server