Hello.
I'm having some problems with binding values with autoselect value from database.
My grid looks like:
(...another columns...)
<telerik:GridViewComboBoxColumn UniqueName="groupCol" DataMemberBinding="{Binding groupList}" DisplayMemberPath="name" SelectedValueMemberPath="gid" Header="Group" >
</telerik:GridViewComboBoxColumn>
And in code behind:
using (SqlCommand cmd = new SqlCommand("SELECT ISNULL(groupID, 0) as gid, (...other values...) ", conn))
{
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
sda.Fill(dt);
cardsDG.ItemsSource = dt.DefaultView;
((GridViewComboBoxColumn)this.cardsDG.Columns["groupCol"]).ItemsSource = getGroups();
}
}
Method to get groups is just select groupID as gid, name from myTable, and add to List<groupList> with public int gid, public string name.
What I'd like to reach is that, if select return ID = 10, I want to select this element in combobox, if isnull is reached, then nothing is selected.
What I'm doing wrong?
I'm having some problems with binding values with autoselect value from database.
My grid looks like:
(...another columns...)
<telerik:GridViewComboBoxColumn UniqueName="groupCol" DataMemberBinding="{Binding groupList}" DisplayMemberPath="name" SelectedValueMemberPath="gid" Header="Group" >
</telerik:GridViewComboBoxColumn>
And in code behind:
using (SqlCommand cmd = new SqlCommand("SELECT ISNULL(groupID, 0) as gid, (...other values...) ", conn))
{
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
sda.Fill(dt);
cardsDG.ItemsSource = dt.DefaultView;
((GridViewComboBoxColumn)this.cardsDG.Columns["groupCol"]).ItemsSource = getGroups();
}
}
Method to get groups is just select groupID as gid, name from myTable, and add to List<groupList> with public int gid, public string name.
What I'd like to reach is that, if select return ID = 10, I want to select this element in combobox, if isnull is reached, then nothing is selected.
What I'm doing wrong?