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

Home >> Forum >> Silverlight >> Post New QuestionBookmark and Share Subscribe to Forum

c# code for datagrid with delete button in silverlight

Posted By: sudhakarreddy     Posted Date: May 14, 2010    Points:2   Category :Silverlight
After check the check boxes (one or more) in the datagrid, i have to delete those rows from the datagrid by clicking the delete button

i want code for following requirements simply
(Check the Rows, execute the query to delete the rows, then rebind the grid)
1) First get the Selected Checked Row items.
2) Delete the records in the DB
3) Rebind the Datagrid

Author: Lalij Mer             
Posted Date: May 14, 2010     Points: 5   

show here grate article will help


Please Check my answer if you help....
Thank You...

Author: Sunil Yadav       [Moderator]      
Posted Date: May 27, 2010     Points: 5   


Check out this..

<data:DataGrid x:Name="dgAssets" ItemsSource="{Binding Data, ElementName=ddsAsset}"

IsReadOnly="True" AutoGenerateColumns="True"
Margin="-209,8,-258,-41" HeadersVisibility="All"/>

<Button x:Name="btnDeleteAsset" Click="btnDeleteAsset_Click" Height="24" Margin="0,0,8,8" VerticalAlignment="Bottom" Content="Delete"/>

private void btnDeleteAsset_Click(object sender, System.Windows.RoutedEventArgs e)
if (dgAssets.SelectedIndex != -1)
int assetid = ((TBAssetRegister)(dgAssets.SelectedItem)).AssetID;

TBAssetRegister objTBAssetRegister = new TBAssetRegister();

var context = ddsAsset.DomainContext as AppDomainContext;

var v = context.TBAssetRegisters.SingleOrDefault(p => p.AssetID == assetid);
objTBAssetRegister = v;
IEditableObject Selectedasset = dgAssets.SelectedItem as TBAssetRegister;


Hope it helps.

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

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