Why cant i do this? (yes another cast question)
Im sorry to be asking so many cast questions lately im still wraping my head around it ( the vet analogy helped)
basicly i am trying to
make a datagridview and insert information from a certian index of invoice binding sources
from that datagridview i want to select a certian row and index ( get the value of one cell basicly)
check to see if that string is empty or null
if so delete that entire line out of invoice binding source
the problem i am running into is with casting ( again) i want invoicedgv to = the value of invoicebindingsource
ive been googleing for the last 2 days and realy cant find anything to point me in the right direction
i assume its one of these possiblitys
1) the invoicedgv reqires something ilke a .value or .cell and i can add the value directly to that. ( i have yet to find anything by pokeing threw inteli sense
2) i am casting wrong ( high probablity)
3) something else
C#
Code:
DataGridView invoicedgv = (DataGridView)invoicebindingsource[index];
String invoiceCheck =invoicedgv["Name",index].ToString().Trim();
if (string.IsNullOrEmpty(invoiceCheck))
{
invoicebindingsource.RemoveAt(index);
}
vb.net = this works
VB Code:
If DirectCast(Me.invoicebindingsource(index), DataRowView)("Name").ToString().Trim() = String.Empty Then
'The Name field does not contain any non-whitespace characters.
Me.invoicebindingsource.RemoveAt(index)
End If
Re: Why cant i do this? (yes another cast question)
You're trying to cast the item from the BindingSource as a DataGridView, not a DataRowView.
We all do spastic stuff. I posted in the Database forum the other day about transactions working with SQL Server Express 2005 and not MSDE2000 when I'd simply stopped the Transaction Coordinator service on MSDE. We're all human. Just some of us don't smell like it. ;)
Re: Why cant i do this? (yes another cast question)
well im getting closer
also with the datarow view i dont need to put the extra indexing information in there becuase its just one row