The way I am currently binding to the grid is via the DataTable control defined here: blogs.telerik.com/vladimirenchev/posts/09-04-23/lightweight_datatable_for_your_silverlight_applications.aspx .
I am looking to create a custom column using the example here: http://www.telerik.com/help/silverlight/gridview-add-button-column.html
The control is comprised of both a textbox and a button. How do I use the GridViewColumn in such a way that the textbox I add is bound to the underlying DataTable for that associated dataItem? I need to later access the underlying value of the textbox in order to save the data.
I am looking to create a custom column using the example here: http://www.telerik.com/help/silverlight/gridview-add-button-column.html
The control is comprised of both a textbox and a button. How do I use the GridViewColumn in such a way that the textbox I add is bound to the underlying DataTable for that associated dataItem? I need to later access the underlying value of the textbox in order to save the data.
Thanks.
5 Answers, 1 is accepted
0
Hello,
Vlad
the Telerik team
I believe that there will be no differences between normal collection and the DataTable in this case.
Regards,Vlad
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Andrew
Top achievements
Rank 1
answered on 05 Apr 2011, 02:43 PM
Yes, I have the previous example working in with the DataTable. What I am asking is: how do I override CreateCellElement() in such a way that the TextBox.Text property is bound to the underlying datasource value for that row/column? I need to display the values in each TextBox to the user, and when he clicks a submit button I need to save the data in the bound data source to a database, but it must reflect any changes made to the Text property of each TextBox.
Below is an example of the simplest implementation of my control:
Below is an example of the simplest implementation of my control:
public
override
FrameworkElement CreateCellElement(Telerik.Windows.Controls.GridView.GridViewCell cell,
object
dataItem)
{
FrameworkElement ele =
base
.CreateCellElement(cell, dataItem);
if
(cell.Content !=
null
)
{
return
(FrameworkElement)cell.Content;
}
return
CreateHeaderControl(cell, dataItem);
}
private
FrameworkElement CreateHeaderControl(Telerik.Windows.Controls.GridView.GridViewCell cell,
object
dataItem)
{
FrameworkElement control =
null
;
TextBox textBox =
null
;
textBox =
new
TextBox();
//How do I bind this Text property to the underlying dataItem value
//for a dynamically generated class in such a way that the TextBox
//displays the value from the data source and updates the value in
//the data source when its Text is changed?
textBox.Text = ???
control = textBox;
cell.Content = control;
return
control;
}
0
Accepted
Hello,
Vlad
the Telerik team
You can use the GridViewDataColumn instead GridViewColumn and bind the DataMemberBinding to the TextBox Text property. Similar implementation can be found on this blog post.
Kind regards,Vlad
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Andrew
Top achievements
Rank 1
answered on 05 Apr 2011, 07:51 PM
Using the described binding with the TwoWay mode does the trick, thanks.
0
Paulo
Top achievements
Rank 1
answered on 03 Oct 2011, 01:25 PM
textBox.SetBinding(ContentControl.ContentProperty, DataMemberBinding);