Advanced Datagrid Question -- Microsoft MVP needed!!

  • Thread starter Thread starter Brad Shook
  • Start date Start date
B

Brad Shook

I am trying to bind one column of a datagrid to a seperate textbox and
the rest of the fields to a datagrid. the comments are too large to
fit in a datagrid so I created a textbox below the datagrid and need
it to hold the data for the current record selected in the datagrid.

The data structure is

Parent Datagrid
Child Datagrid
textbox linked to child datagrid

The code binds everything. The currency manager does not change the
textbox to the next record when I select on the next record in the child
datagrid. it is like it stays on 0 so the text box only shows the 1st
record.

Here is a part of the code.


'DataSetWellMobile1 is the parent dataset with all the data
'DGWellResults is the child datagrid I am binding the data to
'txtWellComments is the textbox that I need bound to the child Datagrid

Me.DataSetWellMobile1.Relations.Add( _
New DataRelation( _
relationName:="relWellInfo", _

parentColumn:=Me.DataSetWellMobile1.Tables("TblPeople").Columns("UniqueId"),
_

childColumn:=Me.DataSetWellMobile1.Tables("TblWellMobileInfo").Columns("Pers
onId"),
_
createConstraints:=True))

Me.DGWellResults.DataBindings.Add(New Binding("DataSource",
Me.DataSetWellMobile1.TblPeople.DefaultView, "relWellInfo"))

Me.txtWellComments.DataBindings.Add(New Binding("Text",
DataSetWellMobile1.TblPeople.DefaultView, "relWellInfo.Comments"))


What am I missing.
Thanks,
Brad
 
I think you are taking the long way around the park here. If you need the
text box to show text upon selection, you only need to handle the
itemcommand event. In this event, you gather your criteria and either fire a
query or loop thru the dataset.

pseudocode in itemdatabound

foreach(datarow dr in DataSetWllMobile1.Items)
if(dr[0].ToString() == e.item.cells[0].Text /*unique id selected in
grid*/)
{
TextBox1.Text = dr[1].ToString(); //or whatever column the data is
located in
break;
}


An alternative to this design would be a column with a link and a mouse-over
event. When the user mouses over, the comments show up as a tooltip. The
idea to do this would be the same as presented above. This way, the UI is
uncluttered with comments since it only appears on user demand.
 
The only problem with this method is I would have to do unnecessary extra
coding to update the dataset when the user types in the comment. That would
be like not linking two datagrids together and manually changing records in
the child datagrid.

Alvin Bruney said:
I think you are taking the long way around the park here. If you need the
text box to show text upon selection, you only need to handle the
itemcommand event. In this event, you gather your criteria and either fire a
query or loop thru the dataset.

pseudocode in itemdatabound

foreach(datarow dr in DataSetWllMobile1.Items)
if(dr[0].ToString() == e.item.cells[0].Text /*unique id selected in
grid*/)
{
TextBox1.Text = dr[1].ToString(); //or whatever column the data is
located in
break;
}


An alternative to this design would be a column with a link and a mouse-over
event. When the user mouses over, the comments show up as a tooltip. The
idea to do this would be the same as presented above. This way, the UI is
uncluttered with comments since it only appears on user demand.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Brad Shook said:
I am trying to bind one column of a datagrid to a seperate textbox and
the rest of the fields to a datagrid. the comments are too large to
fit in a datagrid so I created a textbox below the datagrid and need
it to hold the data for the current record selected in the datagrid.

The data structure is

Parent Datagrid
Child Datagrid
textbox linked to child datagrid

The code binds everything. The currency manager does not change the
textbox to the next record when I select on the next record in the child
datagrid. it is like it stays on 0 so the text box only shows the 1st
record.

Here is a part of the code.


'DataSetWellMobile1 is the parent dataset with all the data
'DGWellResults is the child datagrid I am binding the data to
'txtWellComments is the textbox that I need bound to the child Datagrid

Me.DataSetWellMobile1.Relations.Add( _
New DataRelation( _
relationName:="relWellInfo", _

parentColumn:=Me.DataSetWellMobile1.Tables("TblPeople").Columns("UniqueId"),
_

childColumn:=Me.DataSetWellMobile1.Tables("TblWellMobileInfo").Columns("Pers
onId"),
_
createConstraints:=True))

Me.DGWellResults.DataBindings.Add(New Binding("DataSource",
Me.DataSetWellMobile1.TblPeople.DefaultView, "relWellInfo"))

Me.txtWellComments.DataBindings.Add(New Binding("Text",
DataSetWellMobile1.TblPeople.DefaultView, "relWellInfo.Comments"))


What am I missing.
Thanks,
Brad
 
You have to write the unnecessary extra code any way you choose. the
datagrids do not automagically update. This functionality is only available
in vs.net 05

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Brad Shook said:
The only problem with this method is I would have to do unnecessary extra
coding to update the dataset when the user types in the comment. That
would
be like not linking two datagrids together and manually changing records
in
the child datagrid.

Alvin Bruney said:
I think you are taking the long way around the park here. If you need the
text box to show text upon selection, you only need to handle the
itemcommand event. In this event, you gather your criteria and either
fire a
query or loop thru the dataset.

pseudocode in itemdatabound

foreach(datarow dr in DataSetWllMobile1.Items)
if(dr[0].ToString() == e.item.cells[0].Text /*unique id selected in
grid*/)
{
TextBox1.Text = dr[1].ToString(); //or whatever column the data
is
located in
break;
}


An alternative to this design would be a column with a link and a mouse-over
event. When the user mouses over, the comments show up as a tooltip. The
idea to do this would be the same as presented above. This way, the UI is
uncluttered with comments since it only appears on user demand.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Brad Shook said:
I am trying to bind one column of a datagrid to a seperate textbox and
the rest of the fields to a datagrid. the comments are too large to
fit in a datagrid so I created a textbox below the datagrid and need
it to hold the data for the current record selected in the datagrid.

The data structure is

Parent Datagrid
Child Datagrid
textbox linked to child datagrid

The code binds everything. The currency manager does not change the
textbox to the next record when I select on the next record in the
child
datagrid. it is like it stays on 0 so the text box only shows the 1st
record.

Here is a part of the code.


'DataSetWellMobile1 is the parent dataset with all the data
'DGWellResults is the child datagrid I am binding the data to
'txtWellComments is the textbox that I need bound to the child Datagrid

Me.DataSetWellMobile1.Relations.Add( _
New DataRelation( _
relationName:="relWellInfo", _

parentColumn:=Me.DataSetWellMobile1.Tables("TblPeople").Columns("UniqueId"),
_

childColumn:=Me.DataSetWellMobile1.Tables("TblWellMobileInfo").Columns("Pers
onId"),
_
createConstraints:=True))

Me.DGWellResults.DataBindings.Add(New Binding("DataSource",
Me.DataSetWellMobile1.TblPeople.DefaultView, "relWellInfo"))

Me.txtWellComments.DataBindings.Add(New Binding("Text",
DataSetWellMobile1.TblPeople.DefaultView, "relWellInfo.Comments"))


What am I missing.
Thanks,
Brad
 
Back
Top