Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I am new to silverlight.I am developing datagridview that is bind with collection using WCF service.My Problem here...I am able to popoulate table to datagrid.I am adding selected items to listbox.I am trying to select items in listbox and need to enter some date for that and update in datagrid again.

Here is sample Code:

Student
startDate
Enddate

Paul
08/01/2011


Sam
08/02/2011


Dean
08/03/2011


StartDate


Listbox

Paul

sam


Now If i need select listbox items and assign start date in textbox..update in gridview
Here Is my code:

HTML
<telerik:RadGridView Name="StudentInfoGrid" Grid.Row="2" Grid.ColumnSpan="2"

                                                              ItemsSource="{Binding studentCollection}"

                                                                  SelectedItem="{Binding SelectedStudentInfo,Mode=TwoWay}"

                                                               IsReadOnly="True" SelectionChanged="StudentInfoGrid_SelectionChanged"

                                                              SelectionMode="Single">

                     <telerik:GridViewDataControl.Columns>

                         <telerik:GridViewDataColumn Header="studnet" DataMemberBinding="{Binding studentname}" TextAlignment="Left" Width="*">

                                </telerik:GridViewDataColumn>

                         <telerik:GridViewDataColumn x:Name="StartDate_GridView"   Header="Start Date" DataMemberBinding="{Binding egStartDate,Converter={StaticResource dateConverter}}" MaxWidth="100" />

                         <telerik:GridViewDataColumn Header="End Date" DataMemberBinding="{Binding   egEndDate,Converter={StaticResource dateConverter}}" MaxWidth="100" />



                    </telerik:GridViewDataControl.Columns>



                 </telerik:RadGridView>





                     <telerik:RadDatePicker x:Name="SetStartDate" Grid.Row="0" Grid.Column="1" SelectedValue="{Binding Path=listBoxSelectedItems.SelectedItems.egStartDate,Mode=TwoWay,Converter={StaticResource dateConverter}}" Width="150" HorizontalAlignment="Left"  DisplayFormat="Long" Height="25" />






C#
private void EmployeeGroupbtnClick(object sender, RoutedEventArgs e)

     {

        if (listBoxSelectedItems.SelectedIndex != -1)

          {

             //MessageBox.Show(SetStartDate.SelectedValue.ToString());

             DateTime datePicker1 = SetStartDate.SelectedDate.Value;

              //DateTime datepicker2 = SetEndDate.SelectedDate.Value;



             foreach(var a in listBoxSelectedItems.SelectedItems)

             {

                 Setdate(datePicker1);



                ViewModel.SaveEmployeeGroupAssoc(a as EmployeeGroupAssocData);

             }

           }

      }

     public void Setdate(DateTime datePicker1)

     {



         this.ViewModel.EditedEmployeeGroupAssoc.OriginalEmployeeGroupAssoc.egStartDate = datePicker1;



     }




Please help me out on this issue.

Thankyou in advance
Posted
Updated 23-Sep-11 18:06pm
v2

1 solution

Hello
I believe that you can use an "GridViewTemplateColumn" instead of "GridViewDataColumn".
That way, you can create a template for the cell, using a TextBox or a DateTimePicker-like control to input values.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900