|
I have several textboxes that I need to chang the text when the selection row
is changed in a datagrid. I have the following code. This textbox displayes
the initial selection but when I click on different rows in the datagrid, the
textbox content doesn't change to reflect the change. How can I address
this?
Also, If the user change the text in the textbox then how do I refesh the
display in the datagrid to reflect the changes?
Thanks, Alpha | |
Share:
|
Alpha,
It seems like you either have separate binding contexts, or that you are
binding to different data sources. First off, are the textboxes and data
grid in the same form? If not, then you have to create a binding context
and have the forms share it.
Second, how are you setting the data source in the bindings and the data
source in the grid? If you have a data set with a table, "Table", for
example, the following two are NOT the same:
dataGrid.DataSource = dataSet;
dataGrid.DataMember = "Table";
// Is not the same as.
dataGrid.DataSource = dataSet.Tables["Table"];
Also, are you using any views, by chance? Are you binding to different
views?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com... I have several textboxes that I need to chang the text when the selection row is changed in a datagrid. I have the following code. This textbox displayes the initial selection but when I click on different rows in the datagrid, the textbox content doesn't change to reflect the change. How can I address this?
Also, If the user change the text in the textbox then how do I refesh the display in the datagrid to reflect the changes?
Thanks, Alpha | | |
VListing is the datagrid and it's datasource is a dataset table:
VListing.SetDataBinding(dsVehicle, "VehDetail");
The textbox is only bind to the datagrid through the same dataset table:
txtVName.DataBindings.Add("Text", dsVehicle.Tables["vehDetail"], "VName");
I don't have any view created for this. These controls are all on the same
form.
Thank you, Alpha
"Nicholas Paldino [.NET/C# MVP]" wrote: Alpha,
It seems like you either have separate binding contexts, or that you are binding to different data sources. First off, are the textboxes and data grid in the same form? If not, then you have to create a binding context and have the forms share it.
Second, how are you setting the data source in the bindings and the data source in the grid? If you have a data set with a table, "Table", for example, the following two are NOT the same:
dataGrid.DataSource = dataSet; dataGrid.DataMember = "Table";
// Is not the same as. dataGrid.DataSource = dataSet.Tables["Table"];
Also, are you using any views, by chance? Are you binding to different views?
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Alpha" <Al***@discussions.microsoft.com> wrote in message news:0E**********************************@microsof t.com...I have several textboxes that I need to chang the text when the selection row is changed in a datagrid. I have the following code. This textbox displayes the initial selection but when I click on different rows in the datagrid, the textbox content doesn't change to reflect the change. How can I address this?
Also, If the user change the text in the textbox then how do I refesh the display in the datagrid to reflect the changes?
Thanks, Alpha | | |
Alpha,
That is the problem. You are binding to dsVehicle.Tables["vehDetail"]
in the bindings, and to the data set in the vlisting.
Change the code to set the data bindings in the VListing to:
VListing.SetDataBinding(dsVehicle.Tables["vehDetail"], null);
And it should work.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:E0**********************************@microsof t.com... VListing is the datagrid and it's datasource is a dataset table: VListing.SetDataBinding(dsVehicle, "VehDetail");
The textbox is only bind to the datagrid through the same dataset table: txtVName.DataBindings.Add("Text", dsVehicle.Tables["vehDetail"], "VName");
I don't have any view created for this. These controls are all on the same form.
Thank you, Alpha
"Nicholas Paldino [.NET/C# MVP]" wrote:
Alpha,
It seems like you either have separate binding contexts, or that you are binding to different data sources. First off, are the textboxes and data grid in the same form? If not, then you have to create a binding context and have the forms share it.
Second, how are you setting the data source in the bindings and the data source in the grid? If you have a data set with a table, "Table", for example, the following two are NOT the same:
dataGrid.DataSource = dataSet; dataGrid.DataMember = "Table";
// Is not the same as. dataGrid.DataSource = dataSet.Tables["Table"];
Also, are you using any views, by chance? Are you binding to different views?
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Alpha" <Al***@discussions.microsoft.com> wrote in message news:0E**********************************@microsof t.com... >I have several textboxes that I need to chang the text when the >selection >row > is changed in a datagrid. I have the following code. This textbox > displayes > the initial selection but when I click on different rows in the > datagrid, > the > textbox content doesn't change to reflect the change. How can I > address > this? > > Also, If the user change the text in the textbox then how do I refesh > the > display in the datagrid to reflect the changes? > > Thanks, Alpha | | |
Hummmm, like magic, it's working just great! I don't quite understand. I
followed the databinding sytax for the datagrid, to put datasource as dataset
and the datamember as the table. You have it all specified in the
datasource.
So I guess the textbox binding only looks at the datagrid's datasource and
not the datamember, is that correct? And that's the source of my problem?
Hummmm.... Thank you so much. I wouldn't have been able to figure that one
out myslef for sure.
"Nicholas Paldino [.NET/C# MVP]" wrote: Alpha,
That is the problem. You are binding to dsVehicle.Tables["vehDetail"] in the bindings, and to the data set in the vlisting.
Change the code to set the data bindings in the VListing to:
VListing.SetDataBinding(dsVehicle.Tables["vehDetail"], null);
And it should work.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Alpha" <Al***@discussions.microsoft.com> wrote in message news:E0**********************************@microsof t.com... VListing is the datagrid and it's datasource is a dataset table: VListing.SetDataBinding(dsVehicle, "VehDetail");
The textbox is only bind to the datagrid through the same dataset table: txtVName.DataBindings.Add("Text", dsVehicle.Tables["vehDetail"], "VName");
I don't have any view created for this. These controls are all on the same form.
Thank you, Alpha
"Nicholas Paldino [.NET/C# MVP]" wrote:
Alpha,
It seems like you either have separate binding contexts, or that you are binding to different data sources. First off, are the textboxes and data grid in the same form? If not, then you have to create a binding context and have the forms share it.
Second, how are you setting the data source in the bindings and the data source in the grid? If you have a data set with a table, "Table", for example, the following two are NOT the same:
dataGrid.DataSource = dataSet; dataGrid.DataMember = "Table";
// Is not the same as. dataGrid.DataSource = dataSet.Tables["Table"];
Also, are you using any views, by chance? Are you binding to different views?
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Alpha" <Al***@discussions.microsoft.com> wrote in message news:0E**********************************@microsof t.com... >I have several textboxes that I need to chang the text when the >selection >row > is changed in a datagrid. I have the following code. This textbox > displayes > the initial selection but when I click on different rows in the > datagrid, > the > textbox content doesn't change to reflect the change. How can I > address > this? > > Also, If the user change the text in the textbox then how do I refesh > the > display in the datagrid to reflect the changes? > > Thanks, Alpha | | |
Alpha,
It does look at both the data source and the data member, but it uses
those two things together to determine if the data source is the same.
Since the data source for one was the table, and the data source for the
other was the data set (while the data member was null and the name of the
table respectively), it considers the data sources separate.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:5D**********************************@microsof t.com... Hummmm, like magic, it's working just great! I don't quite understand. I followed the databinding sytax for the datagrid, to put datasource as dataset and the datamember as the table. You have it all specified in the datasource.
So I guess the textbox binding only looks at the datagrid's datasource and not the datamember, is that correct? And that's the source of my problem? Hummmm.... Thank you so much. I wouldn't have been able to figure that one out myslef for sure.
"Nicholas Paldino [.NET/C# MVP]" wrote:
Alpha,
That is the problem. You are binding to dsVehicle.Tables["vehDetail"] in the bindings, and to the data set in the vlisting.
Change the code to set the data bindings in the VListing to:
VListing.SetDataBinding(dsVehicle.Tables["vehDetail"], null);
And it should work.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Alpha" <Al***@discussions.microsoft.com> wrote in message news:E0**********************************@microsof t.com... > VListing is the datagrid and it's datasource is a dataset table: > VListing.SetDataBinding(dsVehicle, "VehDetail"); > > The textbox is only bind to the datagrid through the same dataset > table: > txtVName.DataBindings.Add("Text", dsVehicle.Tables["vehDetail"], > "VName"); > > I don't have any view created for this. These controls are all on the > same > form. > > Thank you, Alpha > > "Nicholas Paldino [.NET/C# MVP]" wrote: > >> Alpha, >> >> It seems like you either have separate binding contexts, or that >> you >> are >> binding to different data sources. First off, are the textboxes and >> data >> grid in the same form? If not, then you have to create a binding >> context >> and have the forms share it. >> >> Second, how are you setting the data source in the bindings and >> the >> data >> source in the grid? If you have a data set with a table, "Table", for >> example, the following two are NOT the same: >> >> dataGrid.DataSource = dataSet; >> dataGrid.DataMember = "Table"; >> >> // Is not the same as. >> dataGrid.DataSource = dataSet.Tables["Table"]; >> >> Also, are you using any views, by chance? Are you binding to >> different >> views? >> >> >> -- >> - Nicholas Paldino [.NET/C# MVP] >> - mv*@spam.guard.caspershouse.com >> >> "Alpha" <Al***@discussions.microsoft.com> wrote in message >> news:0E**********************************@microsof t.com... >> >I have several textboxes that I need to chang the text when the >> >selection >> >row >> > is changed in a datagrid. I have the following code. This textbox >> > displayes >> > the initial selection but when I click on different rows in the >> > datagrid, >> > the >> > textbox content doesn't change to reflect the change. How can I >> > address >> > this? >> > >> > Also, If the user change the text in the textbox then how do I >> > refesh >> > the >> > display in the datagrid to reflect the changes? >> > >> > Thanks, Alpha >> >> >> | | |
Thank you.
"Nicholas Paldino [.NET/C# MVP]" wrote: Alpha,
It does look at both the data source and the data member, but it uses those two things together to determine if the data source is the same. Since the data source for one was the table, and the data source for the other was the data set (while the data member was null and the name of the table respectively), it considers the data sources separate.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Alpha" <Al***@discussions.microsoft.com> wrote in message news:5D**********************************@microsof t.com... Hummmm, like magic, it's working just great! I don't quite understand. I followed the databinding sytax for the datagrid, to put datasource as dataset and the datamember as the table. You have it all specified in the datasource.
So I guess the textbox binding only looks at the datagrid's datasource and not the datamember, is that correct? And that's the source of my problem? Hummmm.... Thank you so much. I wouldn't have been able to figure that one out myslef for sure.
"Nicholas Paldino [.NET/C# MVP]" wrote:
Alpha,
That is the problem. You are binding to dsVehicle.Tables["vehDetail"] in the bindings, and to the data set in the vlisting.
Change the code to set the data bindings in the VListing to:
VListing.SetDataBinding(dsVehicle.Tables["vehDetail"], null);
And it should work.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Alpha" <Al***@discussions.microsoft.com> wrote in message news:E0**********************************@microsof t.com... > VListing is the datagrid and it's datasource is a dataset table: > VListing.SetDataBinding(dsVehicle, "VehDetail"); > > The textbox is only bind to the datagrid through the same dataset > table: > txtVName.DataBindings.Add("Text", dsVehicle.Tables["vehDetail"], > "VName"); > > I don't have any view created for this. These controls are all on the > same > form. > > Thank you, Alpha > > "Nicholas Paldino [.NET/C# MVP]" wrote: > >> Alpha, >> >> It seems like you either have separate binding contexts, or that >> you >> are >> binding to different data sources. First off, are the textboxes and >> data >> grid in the same form? If not, then you have to create a binding >> context >> and have the forms share it. >> >> Second, how are you setting the data source in the bindings and >> the >> data >> source in the grid? If you have a data set with a table, "Table", for >> example, the following two are NOT the same: >> >> dataGrid.DataSource = dataSet; >> dataGrid.DataMember = "Table"; >> >> // Is not the same as. >> dataGrid.DataSource = dataSet.Tables["Table"]; >> >> Also, are you using any views, by chance? Are you binding to >> different >> views? >> >> >> -- >> - Nicholas Paldino [.NET/C# MVP] >> - mv*@spam.guard.caspershouse.com >> >> "Alpha" <Al***@discussions.microsoft.com> wrote in message >> news:0E**********************************@microsof t.com... >> >I have several textboxes that I need to chang the text when the >> >selection >> >row >> > is changed in a datagrid. I have the following code. This textbox >> > displayes >> > the initial selection but when I click on different rows in the >> > datagrid, >> > the >> > textbox content doesn't change to reflect the change. How can I >> > address >> > this? >> > >> > Also, If the user change the text in the textbox then how do I >> > refesh >> > the >> > display in the datagrid to reflect the changes? >> > >> > Thanks, Alpha >> >> >> | | This discussion thread is closed Replies have been disabled for this discussion. Similar topics
1 post
views
Thread by Amadelle |
last post: by
|
13 posts
views
Thread by Paul Slavin |
last post: by
|
2 posts
views
Thread by Alpha |
last post: by
|
2 posts
views
Thread by Manish |
last post: by
|
1 post
views
Thread by Amadelle |
last post: by
|
16 posts
views
Thread by Adda |
last post: by
|
2 posts
views
Thread by jose.mendez22 |
last post: by
| | | | | | | | | | |