Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Updating via a datagridview using LINQ

46 views
Skip to first unread message

Jason Eipp

unread,
Jul 6, 2009, 12:49:01 PM7/6/09
to
Hello,

I cannot seem to get my datagridview to update the database using LINQ. I
have my dbml set up and I can perform updates if I use textboxes.

Here is the situation:

combobox1 one populates combobox2 on a selected index change for combobox1
combobox2 populates the datagridview on a selected index change for combobox2

private void combobox2_SelectedIndexChanged(object sender, EventArgs e)
{
var MarkupsQuery = from dealer_markup in intData1.dealer_markups
where dealer_markup.category ==
cboCategoryFee.SelectedValue.ToString()
&& dealer_markup.schedule_id ==
cboCoveragesFee.SelectedValue.ToString()
&& dealer_markup.dealer_id ==
cboDealership.SelectedValue.ToString()
select dealer_markup;
dealer_markupsBindingSource.DataSource = MarkupsQuery;
}
//this returns the correct data

private void btnSubmit_Click(object sender, EventArgs e)
{
try
{
dealer_markupsDataGridView.Update();
intData1.SubmitChanges();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "ERROR");
}

}
//this is where "Specified cast is not valid" error message is displayed

Thanks for the help!

v/r,

Jason

0 new messages