467,859 Members | 1,299 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,859 developers. It's quick & easy.

DataGrid Functionality Questions

I have a DataGrid in a web form (ASP1.1, C#, VS 2003) that I'm trying to add
some functionality to, and I can't figure out how to do int.

The existing DataGrid has several databound columns and a Template Columns,
into which I put buttons. When the user clicks on the 'Do It' button, the
selection is recorded in an underlying database, and (almost) everything is
fine. One thing I would like to improve in the existing version concerns
the state of the datagrid in the postback. I would like to scroll to the
row the user just clicked on.

I have to add DropDownList controls to some of the rows, based on database
driven considerations. I added template columns to the DataGrid, and
inserted DropDownLists into these columns, as well as two invisible
databound columns, Number_Of_Category1_Fields, Number_Of_Category2_Fields.

In the DataTier I add fields Number_Of_Category1_Fields,
Number_of_Category2_Field to the main table, and added tables
Category1_Fields, Category2_Fields.

In the Page_Load method I create & populate the DataGrid.
I loop over the DataGrid.Items collection, and if the entries for
Number_Of_Category1_Fields > 0, I retrieve the entries from the table
Category1_Fields and insert them into the appropriate DropDownList ( same
for Category2 ), setting the DropDownList.Visible = true

In the DataGridItemEvent, i.e. user clicked the 'Do It' button, I check to
see if the DropDownLists are populated, if so I retrieve the selected value
and insert these into the database as appropriate. Again, all works well

My problem is how to trap instances where the user clicks the 'Do It'
button where they haven't made a selection in one or more of the
DropDownLists. I would like to do this before the PostBack, so the error
trapping can't be performed in the 'Do It' button. I was thinking of having
the 'Do It' buttons disabled, and enabling them with JavaScript when the
user selects from the DropDownLists, but I don't know how to add that
functionality within the context of a DataGrid ( i.e. how does one retrieve
the ControlID of the DropDownList to get the names of the other
DropDownList and the button? )

So, my question is, how does one do this well?

Thanks

Phil
Feb 13 '06 #1
  • viewed: 1469
Share:
3 Replies
OK, you need to add achors in each row in a column ( Bookmarks ) and then
set a field with the bookmark name so that when the page loads you check
using Jscript if the field has a value, if it does, jump to it,

--
Terry Burns
http://TrainingOn.net
"Phillip N Rounds" <pr*****@cassandragroup.com> wrote in message
news:uZ**************@TK2MSFTNGP09.phx.gbl...
I have a DataGrid in a web form (ASP1.1, C#, VS 2003) that I'm trying to
add some functionality to, and I can't figure out how to do int.

The existing DataGrid has several databound columns and a Template
Columns, into which I put buttons. When the user clicks on the 'Do It'
button, the selection is recorded in an underlying database, and (almost)
everything is fine. One thing I would like to improve in the existing
version concerns the state of the datagrid in the postback. I would like
to scroll to the row the user just clicked on.

I have to add DropDownList controls to some of the rows, based on
database driven considerations. I added template columns to the
DataGrid, and inserted DropDownLists into these columns, as well as two
invisible databound columns, Number_Of_Category1_Fields,
Number_Of_Category2_Fields.

In the DataTier I add fields Number_Of_Category1_Fields,
Number_of_Category2_Field to the main table, and added tables
Category1_Fields, Category2_Fields.

In the Page_Load method I create & populate the DataGrid.
I loop over the DataGrid.Items collection, and if the entries for
Number_Of_Category1_Fields > 0, I retrieve the entries from the table
Category1_Fields and insert them into the appropriate DropDownList ( same
for Category2 ), setting the DropDownList.Visible = true

In the DataGridItemEvent, i.e. user clicked the 'Do It' button, I check to
see if the DropDownLists are populated, if so I retrieve the selected
value and insert these into the database as appropriate. Again, all works
well

My problem is how to trap instances where the user clicks the 'Do It'
button where they haven't made a selection in one or more of the
DropDownLists. I would like to do this before the PostBack, so the
error trapping can't be performed in the 'Do It' button. I was thinking
of having the 'Do It' buttons disabled, and enabling them with JavaScript
when the user selects from the DropDownLists, but I don't know how to add
that functionality within the context of a DataGrid ( i.e. how does one
retrieve the ControlID of the DropDownList to get the names of the other
DropDownList and the button? )

So, my question is, how does one do this well?

Thanks

Phil

Feb 13 '06 #2
Lets say I have an invisible text box on the webform containing a unique
reference to an element in my DataGrid, e.g.

dgMyGrid__ctl2_Field1 - this is the derived form field name which
ASP.NET created for a column in one of my table rows.

How can I 'Jump to it' in JavaScript?

Thanks
"Terry Burns" <me@mine.com> wrote in message
news:e6**************@TK2MSFTNGP14.phx.gbl...
OK, you need to add achors in each row in a column ( Bookmarks ) and then
set a field with the bookmark name so that when the page loads you check
using Jscript if the field has a value, if it does, jump to it,

--
Terry Burns
http://TrainingOn.net
"Phillip N Rounds" <pr*****@cassandragroup.com> wrote in message
news:uZ**************@TK2MSFTNGP09.phx.gbl...
I have a DataGrid in a web form (ASP1.1, C#, VS 2003) that I'm trying to
add some functionality to, and I can't figure out how to do int.

The existing DataGrid has several databound columns and a Template
Columns, into which I put buttons. When the user clicks on the 'Do It'
button, the selection is recorded in an underlying database, and (almost)
everything is fine. One thing I would like to improve in the existing
version concerns the state of the datagrid in the postback. I would like
to scroll to the row the user just clicked on.

I have to add DropDownList controls to some of the rows, based on
database driven considerations. I added template columns to the
DataGrid, and inserted DropDownLists into these columns, as well as two
invisible databound columns, Number_Of_Category1_Fields,
Number_Of_Category2_Fields.

In the DataTier I add fields Number_Of_Category1_Fields,
Number_of_Category2_Field to the main table, and added tables
Category1_Fields, Category2_Fields.

In the Page_Load method I create & populate the DataGrid.
I loop over the DataGrid.Items collection, and if the entries for
Number_Of_Category1_Fields > 0, I retrieve the entries from the table
Category1_Fields and insert them into the appropriate DropDownList ( same
for Category2 ), setting the DropDownList.Visible = true

In the DataGridItemEvent, i.e. user clicked the 'Do It' button, I check
to see if the DropDownLists are populated, if so I retrieve the selected
value and insert these into the database as appropriate. Again, all
works well

My problem is how to trap instances where the user clicks the 'Do It'
button where they haven't made a selection in one or more of the
DropDownLists. I would like to do this before the PostBack, so the
error trapping can't be performed in the 'Do It' button. I was thinking
of having the 'Do It' buttons disabled, and enabling them with JavaScript
when the user selects from the DropDownLists, but I don't know how to add
that functionality within the context of a DataGrid ( i.e. how does one
retrieve the ControlID of the DropDownList to get the names of the other
DropDownList and the button? )

So, my question is, how does one do this well?

Thanks

Phil


Feb 13 '06 #3
Well when you bind the grid to the datasource, this DataBind event is called
each row, you can add Anchor;s to each row at this point. You will at least
be able to loacate the page at the anchor point. Once you go into edit mode
you set a hidden field on the form to a computed anchor name.

"#" & EditIndex.tostring

Add an onLoad event script to your page which interrogates this field and if
it has a value in it, is javascript to jump to the bookmark.

In page_load in asp.net, you need to zap this each time so you dont
continually jump to it after it is set once.

--
Terry Burns
http://TrainingOn.net
"Phillip N Rounds" <pr*****@cassandragroup.com> wrote in message
news:OM**************@TK2MSFTNGP11.phx.gbl...
Lets say I have an invisible text box on the webform containing a unique
reference to an element in my DataGrid, e.g.

dgMyGrid__ctl2_Field1 - this is the derived form field name which
ASP.NET created for a column in one of my table rows.

How can I 'Jump to it' in JavaScript?

Thanks
"Terry Burns" <me@mine.com> wrote in message
news:e6**************@TK2MSFTNGP14.phx.gbl...
OK, you need to add achors in each row in a column ( Bookmarks ) and then
set a field with the bookmark name so that when the page loads you check
using Jscript if the field has a value, if it does, jump to it,

--
Terry Burns
http://TrainingOn.net
"Phillip N Rounds" <pr*****@cassandragroup.com> wrote in message
news:uZ**************@TK2MSFTNGP09.phx.gbl...
I have a DataGrid in a web form (ASP1.1, C#, VS 2003) that I'm trying to
add some functionality to, and I can't figure out how to do int.

The existing DataGrid has several databound columns and a Template
Columns, into which I put buttons. When the user clicks on the 'Do It'
button, the selection is recorded in an underlying database, and
(almost) everything is fine. One thing I would like to improve in the
existing version concerns the state of the datagrid in the postback. I
would like to scroll to the row the user just clicked on.

I have to add DropDownList controls to some of the rows, based on
database driven considerations. I added template columns to the
DataGrid, and inserted DropDownLists into these columns, as well as two
invisible databound columns, Number_Of_Category1_Fields,
Number_Of_Category2_Fields.

In the DataTier I add fields Number_Of_Category1_Fields,
Number_of_Category2_Field to the main table, and added tables
Category1_Fields, Category2_Fields.

In the Page_Load method I create & populate the DataGrid.
I loop over the DataGrid.Items collection, and if the entries for
Number_Of_Category1_Fields > 0, I retrieve the entries from the table
Category1_Fields and insert them into the appropriate DropDownList (
same for Category2 ), setting the DropDownList.Visible = true

In the DataGridItemEvent, i.e. user clicked the 'Do It' button, I check
to see if the DropDownLists are populated, if so I retrieve the selected
value and insert these into the database as appropriate. Again, all
works well

My problem is how to trap instances where the user clicks the 'Do It'
button where they haven't made a selection in one or more of the
DropDownLists. I would like to do this before the PostBack, so the
error trapping can't be performed in the 'Do It' button. I was thinking
of having the 'Do It' buttons disabled, and enabling them with
JavaScript when the user selects from the DropDownLists, but I don't
know how to add that functionality within the context of a DataGrid (
i.e. how does one retrieve the ControlID of the DropDownList to get the
names of the other DropDownList and the button? )

So, my question is, how does one do this well?

Thanks

Phil



Feb 14 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Kevin | last post: by
1 post views Thread by Torre Quinn | last post: by
3 posts views Thread by Jim Heavey | last post: by
1 post views Thread by Craig Banks | last post: by
1 post views Thread by Tom | last post: by
9 posts views Thread by John Hernry | last post: by
9 posts views Thread by Steve | last post: by
4 posts views Thread by cooltech77 | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.