Re: Vb.net 2008 Datagridview bound/unbound columns update datasour
- From: Sergey Poberezovskiy <Sergey Poberezovskiy@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 24 Nov 2009 13:55:02 -0800
Rob,
If you do not need to store the column information - no need to:
Consider the following code:
Dim source As DataTable = getDataFromSqlServer()
source.Columns.Add("Selected", GetType(Boolean))
myDataGridView.DataSource = source
This way you only use the column where you need it.
Also there is no need to use FormattedValue, you can use Value instead:
Bookings.Cells("selectColumn").Value = True
Hope this helps
"Rob W" wrote:
Thanks for the suggestion I had thought of this but was interested in.
alternatives, with nothing forth coming I decided to store the column
though not really data
as is used to select rows for the purpose of deletion.
Ensuring I check the formatted value in a loop to remove the data e.g.
Bookings.Cells("selectColumn").FormattedValue = "True"
I created a new field as a bit to store the value of the
datagridviewcheckboxcell in SQLServer e.g.
Select CAST( 0 as bit) AS selectColumn
All works as intended now :-)
Thanks
Rob
"Sergey Poberezovskiy" <SergeyPoberezovskiy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote
in message news:797E0D52-CFA4-4175-9ED3-830063ABDFCA@xxxxxxxxxxxxxxxx
Rob,
I might be wrong, but I suspect that because the grid checkbox column is
not
bound, then during DataSource change (when you remove the row) it resets
unbound columns to the default values - unchecked.
Is there any reason why you need the checkboxes unbound - you may add a
(boolean) column to the table and then bound the checkboxcolumn to that.
This
way grid should know where to get the values for individual rows from.
Hope this helps
"Rob W" wrote:
Greetings,
Well this is really a continuation from a previous thread and I've
exhausted
all my resources in finding an answer so posting in it's own thread.
A datagridview is created programmatically and then the datasource is set
to
a dataset with all but the datagridviewcheckboxcells bound using the
dataproperty option.
If I change the underlying datasoure I.e. the datatable (e.g. removing a
datarow) then the unbound columns if checkbox values are selected i.e.
true
are ALL set to false.
Is this usual behaviour? Can I prevent this?
I couldn't find a single item on the Internet to reference anyone else
experiencing the same, apologies if being really stupid but need some
guidance here, can anyone please offer some advice and guidance?
Thanks
Rob
.
.
- Follow-Ups:
- References:
- Prev by Date: Re: date conversion problem
- Next by Date: Re: date conversion problem
- Previous by thread: Re: Vb.net 2008 Datagridview bound/unbound columns update datasource e
- Next by thread: Re: Vb.net 2008 Datagridview bound/unbound columns update datasour
- Index(es):
Relevant Pages
|