Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello I need help in being able to select a row in a data repeater and be able to pass its value so I can delete that record. I have scoured the internet and cannot figure this out.

Thanks,

Korrowan
Posted

1 solution

What DataRepeater?

Where did the code come from for the DataRepeater?
 
Share this answer
 
Comments
korrowna 29-Mar-11 22:35pm    
The VB powerpack DataRepeater that is available in VS 2008 SP1+
Henry Minute 30-Mar-11 7:36am    
The currently selected item can be accessed with the CurrentItem property or you can use the CurrentItemIndex also. Once selected I suspect, although I haven't tried it, that Ctl-Del will delete that item.

There are a series of 'HowTo' articles on MSDN -->http://msdn.microsoft.com/en-us/library/cc488279.aspx. You may be able to get enough information by reading/working through them.
korrowna 30-Mar-11 8:22am    
Thank you Henry. I will read through that and see if I can figure this out. Out of curiosity Ctl-Del will delete the row but not the record correct?
Henry Minute 30-Mar-11 8:32am    
Ctl-Del is the 'standard' method for grid like controls and whether it will delete record depends on how the databinding is set up. If it works for the DataRepeater at all, it should delete the row from the in-memory datastore if you use one.
korrowna 30-Mar-11 9:15am    
Well here is what I did and it functions... not sure if its the best solution just thought I would share.

One thing I thought that was odd is when I attempted to use datarepeater1.endresetitemtemplate() it actually flashed the record off and then back onto the screen but without it it works. Either way it seems to function as intended!

private void cmdDeleteDoc_Click(object sender, EventArgs e)
{
//check to see if currentitem is 0
if (this.dataRepeater1.CurrentItemIndex == 0)
{



//begin reset
this.dataRepeater1.BeginResetItemTemplate();
// Delete Row Here

DataClasses1DataContext db = new DataClasses1DataContext();

System.Data.DataRowView SelectedRowView;
newCityCollectionDataSet.DocumentsRow SelectedRow;

SelectedRowView = (System.Data.DataRowView)documentsBindingSource.Current;
SelectedRow = (newCityCollectionDataSet.DocumentsRow)SelectedRowView.Row;

var matchedDocument = (from c in db.GetTable<document>()
where c.DocIDKey == SelectedRow.DocIDKey
select c).SingleOrDefault();

db.Documents.DeleteOnSubmit(matchedDocument);
db.SubmitChanges();


LoadCaseNumberKey(matchedDocument.CaseNumberKey, false, "docuements");





}
}

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