.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

DataGridComboBox - pouplated combobox with values but can't get selected value from the datagrid da

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :JQuery

I'm still learning WPF so doing something that I thought would be fairly straight forward. <Slap forehead> ... looks like I need to take more time with this.
Hoping that someone can help me with this:

I'm populating a combobox in a datagrid and this works.
I'm populating the datagrid using another dataset.  The combobox is not taking the stored value this dataset and setting it in the combobox as selected.

Here's the xaml:

  <DataGrid x:Name="dgNoteDetail" AutoGenerateColumns="False" Grid.Column="1" Grid.Row="6" Grid.ColumnSpan="10" ItemsSource="{Binding}">
                <DataGridTextColumn Header="ID" Visibility="Hidden" Binding="{Binding Path=ID}"/>
                <DataGridTextColumn Header="Notes" Width="*" Binding="{Binding Path=Notes}"/>
                <DataGridComboBoxColumn Width="90" Header="Importance" SelectedItemBi

View Complete Post

More Related Resource Links

Configure BDC column to have multiple values selected


How do I Configure BDC column to have multiple values selected and make multiple entities data available in the same column.  Currently it supports only single value for an item.  This requirement is crucial need some solution immediately.

How do you create a custom BDC data field that allows for multiple selected values?

I need help creating a custom data field using the BDC column as a base.  We need to allow for multiple selected values instead of just a single one.  I can't find anything on the net which shows how to do this.

Retain DropDown,TextBox's previously selected values after redirected from another page.


 Hi People, How are you all doing?

I have 2 pages one is SearchPage & It has DropDowns, textboxes to specify the search criteria. From the search result the user is redirected to another page when he clicks the hyperlink in the search result  where he fills in the information and again redirected to SearchPage. Now the SearchPage is posted back with no state i just want to retain the search criteria and display when user comes back. Please give me some suggestion how to get this done. I've used ViewState to save the values and check them in Page_Load but they are null.   



 Update: I've come up with this code. But the problem is The values are being retained but the Button_Click event is not being handled properly. When i Check the code even after this "DropDownList1.SelectedValue = Session["Name"].ToString();" DownList1.SelectedValue is EMPTY"" samw with DropDownList2 . please Suggest something


    protected void Page_Load(object sender, EventArgs e)
        if (IsControlsEmpty())
            if (SessionExist())
                DropDownList1.SelectedValue = Session["Name"].ToString()

how to get selected value from combobox?

i have combobox which populated with data from sql db now when user select value i want to get selected value in combobox in this code i get the place of the value in sql table but not value himself can anyone help me??   private   void button1_Click(object sender, RoutedEventArgs e) {     int selectedIndex = comboBox9.SelectedIndex;   Object selectedItem = comboBox9.SelectedItem;   MessageBox.Show("Selected Item Text: " + selectedItem.ToString() + "\n" +   "Index: " + selectedIndex.ToString()); } i get showbox  "  slected item text system.data.dataRowView"

WPF Datagrid Combobox column

Hi, I am creating a WPF Datagrid with the combobox column in it. All the datagrid binding and combobox column binding works fine without any problem. But, when I select a value in the combobox column and move to the next column or row, the value is reset to the previous empty selection. Am I missing anything here? Please find the code snippet that I have used below. <dg:DataGridComboBoxColumn x:Name="technicianname" Header="Assigned To" ItemsSource="{Binding}"/> technicianname.ItemsSource = dtTechnicianInfo.DefaultView; technicianname.DisplayMemberPath = "TechnicianName"; technicianname.SelectedValuePath = "TechnicianEid"; Thanks in Advance!!! Best Regards, Subalakshmi Vijayarajan.

How to get the combobox value inside Datagrid on Edit button click event

Hi     I have Datagrid template column like<DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn>DataGridTemplateColumn Header="Edit" x:Name="Edit" ><DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn.CellEditingTemplate></DataGridTemplateColumn>SelectionChanged="cmbDGTeam_SelectionChanged" IsTabStop="True" /></DataTemplate><ComboBox Height="22" IsEditable="True" IsReadOnly="True" ItemsSource="{Binding}" DisplayMemberPath="Title" SelectedValuePath="TeamID" x:Name="cmbDGTeam"  SelectedValue="{Binding Path=TeamID,Mode=TwoWay}"<DataGridTemplateColumn.CellEditingTemplate><DataTemplate><DataTemplate><TextBlock Text="{Binding Title}"/></DataTemplate></DataGridTemplateColumn.CellTemplate><DataGridTemplateColumn Header="Team" Width="75"><DataGridTemplateColumn.CellTemplate> and Edit button Template column <DataGridTemplateColumn Header="Edit" x:Name="Edit" > </DataGridTemplateColumn.CellTemplate></DataTemplate><Button Content="Edit" IsEnabled="False" x:Name="btnEdit" Click="btnEdit_Click" ></Button>&l

Accessing Combobox inside WPF Datagrid Template Column

Hi, I am creating a WPF datagrid template column with combobox. The problem that I face now is, I am not able to bind a table to the combobox inside the WPF datagrid template column. Here is the code snippet. <dg:DataGrid x:Name="Students" AutoGenerateColumns="False" Loaded="OnLoad"> <dg:DataGrid.Columns> <dg:DataGridTextColumn Binding="{Binding Path=Name}" Header="Name" Width="75"/> <dg:DataGridTemplateColumn x:Name="Dept"> <dg:DataGridTemplateColumn.CellTemplate> <DataTemplate> <ComboBox x:Name="DeptId" ItemsSource="{Binding}" SelectionChanged="Dept_SelectionChanged" DisplayMemberPath="{Binding Path=DeptName}" SelectedValuePath="{Binding Path=DeptId}" SelectedItem="{Binding Path=Belongs}"/> </DataTemplate> </dg:DataGridTemplateColumn.CellTemplate> </dg:DataGridTemplateColumn> </dg:DataGrid.Columns> </dg:DataGrid> Please help me to find out the way to assign a dynamic source to the combobox through code behind file. Thanks in Advance!!! Best Regards, Subalakshmi Vijayarajan.

WPF get selected cells on sorted datagrid

hello, how can i get the selected rows - and then each (visible) cell separately on a sorted datagrid? something like datagrid.SelectedCells[i][j], but with sorting taken onto account. Thanks

ComboBox in non selected accordion Pane do not render correctly

the combo boxes in the originally selected accordion pane work just fine. But when I navigate to one of the other pane those combo boxes show up as a textbox with a very tiny square button for a dropdown arrow and no popup dropdown list to select from. below is my code for the accordion<cc1:Accordion ID="Accordion1" HeaderCssClass="accordionHeader"              HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent" Font-Bold="True" runat="server">             <Panes>                 <cc1:AccordionPane ID="aP1" runat="server">                     <Header >ComboBox 1</Header>                     <Content>                         <cc1:ComboBox ID="cmb1" runat="server" RenderMode="Block">                             <asp:ListItem Text="item 1"></asp:ListItem>                 

Get Cell Value of DataGridComboBox Column for WPF DataGrid

hello Friends I am using WPF Datagrid (WPFToolKit Control) in my appliction I Have a DataGridComboBox Column which is filled with some records.  <WpfToolkit:DataGridComboBoxColumn ScrollViewer.CanContentScroll="True" CellStyle="{StaticResource LeftAlignedCellStyle}" Header="Item Code" x:Name="CmbItems" Width="250" SelectedValueBinding="{Binding ITEMCODE}" DisplayMemberPath="ITEMDESC" SelectedValuePath="ITEMCODE"  > </WpfToolkit:DataGridComboBoxColumn> Now how to get selectedText of that combobox for current row. my current focus on other cell  Please Help Me regards Vipul

DataGrid ComboBox crash

Maybe someone can figure out this issue. I downloaded a working example of a DataGrid Combobox and confirmed that it worked.  I basically copied the template into my application, but it's not working totally correct.  I can't find the difference in my code that is causing the problem. 1.  The values are bound correct in the combobox, but when I click twice, the drop down box appears, but the value nulls out.  In the working example, the value stays in the box.  What is causing this? 2.  When I change the value, the value selects OK.  But, when I click again (to save), I get a 'Two-Way Binding requires Path or XPath' exception.  The thing is there is no Path or XPath statement in the working example code.  What is causing this error?   Sutton  

Adding new rows to Datagrid with a Combobox column generate "two-way binding requires path or xpath"



    I have datagrid control with a template combobox column like:

 <DataGridTemplateColumn Header="Fault code" Width="75">
                                    <TextBlock Text="{Binding FaultCode1}" />

Insert checkboxlist selected values into sql table using createuser wizard



I am using CreateUserWizard control where I collect personal information from the user on the first step (ie. name, address, tel, mobile etc) then on the second step I collect information for membership service (ie. user name, password, email etc). When user clicks Create button, information is sent to two different tables in the same database. Everything works fine but one.

In the first step where I collect personal information, I also collect details about Interest which is a CheckBoxList (CheckBoxList is getting values from Interests table: 1-White, 2-Green, 3-Brown, 4-Maroon, 5-Yellow).

What I want to do is, when client selects his itnerest categories and clicks Create button, to send selected values from CheckBoxList into the third table called Categories. I want values to be registered into the CatCode column in Interests table as comma delimited. For example: if client selected "White", "Green" and "Yellow", appropriate values for those interests (such as 1, 3, 5) to be registered under Categories table CatCode column (like: 1,3,5).

Following is my code:

<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" 

Values in multiselect dropdown not getting selected when Select All option is selected


Values in multiselect dropdown not getting selected when Select All option is selected for a SSRS dropdown.

There are multiple dropdowns on the page. We have one dropdown whose output is being used to populate the second dropdown using a stored procedure. When we check the Select All checkbox on the dropdown then ideally upon page refresh all the values should get selected in the dropdown, but in this case the page refreshes back to the blank dropdown, forcing the user to select the values again. The next dropdown too does not get populated. This makes it impossible to run the report for all the cases by using Select All.

We ran the report on differnet database environments. My current location is Mumbai,India, the report worked fine when we ran it on a Bangalore,india database. This issue occurs when we try running it on a Chicago database server.

I am using SSRS 2005, SQL2005.

If anybody has faced such an issue earlier, please help me out here.  Thank you. 


How Get selected cell values from gridview


How Get particular selected cell value from gridview . my grid so many cell available..

i'm created dynamic row and cell ...

combobox in datagrid with MVVM Pattern



  i have requirement that, datagrid has a two column one is text column and other is combo box, combo box contain 2 column including checkbox. once i click the checkbox in combobox, resepective first column value need to display in combo box selected item and second column values need to display in first column of the data grid.

  I have used following code in xmal


<DataGrid x:Name="dgMixture"  VerticalAlignment="Top"  Width="250"
                      RowHeight="25"  GridLinesVisibility="Vertical" HeadersVisibility="Column" IsReadOnly="True"  AutoGenerateColumns="False"
                      HorizontalAlignment="Left" CanUserAddRows="False" ItemsSource="{Binding CompanyItemsCV}"   >

Adding Multiple Selected Values to ListBox Dynamically


I have a ListBox control that gets populated from a database like this:

For Each gvr As GridViewRow In GridView1.Rows
                Dim lb As ListBox = CType(gvr.FindControl("SectionsListBox"), ListBox)
                For Each sect As String In sectionlist


Then the selected values also get populated like this:

For Each gvr As GridViewRow In GridView1.Rows
                Dim lb As ListBox = CType(gvr.FindControl("SectionsListBox"), ListBox)
                Dim faqid As Integer = gvr.Cells(0).Text
                selectedlist = oCMS.getFAQSections(faqid)
                For Each sect As String In selectedlist
                    lb.SelectedValue += sect


I need to have multiple selections, but I cannot get it to select multiple values with this line "lb.SelectedValue += sect".  The listbox has been set in aspx to allow multiple selections.


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend