How do I loop through all checkboxes loaded by
public void loadTags()
{
DataTable dt = new DataTable();
using (SqlCommand selectTags = new SqlCommand("select tag from Categories", cs))
{
cs.Open();
using (SqlDataAdapter dataAd = new SqlDataAdapter(selectTags))
{
dt = new DataTable();
dataAd.Fill(dt);
}
cs.Close();
}
list1.ItemsSource = dt.DefaultView;
}
xaml:
<ListView Name="list1" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="307,52,0,0" Height="132" Width="293">
<ListView.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding tag}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
do you have any idea how do I get now all tag names (checkboxes) using loop?
If I hardcode these checkboxes straight into grid this loop is working. But if I get them straight from the database i only get System.Data.DataRowView instead of spo, inf, war etc if these checkboxes are checked.
foreach (var items in list1.Items)
{
if (items.IsChecked == true)
{
list.Add("CategoryMulti like '%" + item.Content.ToString() + "%'");
}
}
Aucun commentaire:
Enregistrer un commentaire