473,507 Members | 2,441 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
3 1697
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1336
by: Kevin | last post by:
Hi Al I have two questions about a datagrid, I need to decide which way to go.... I have a datagrid that will show me all the entries in a table. When I click on any cell(actually I would...
1
3719
by: Torre Quinn | last post by:
Does anyone have any good sites or resources dealing with adding drag and drop functionality to a set of controls on a form? I'd like to try to get several examples of varied applications of drag...
3
4856
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
2
2316
by: Sky | last post by:
Hello: Another question about trying to wring functionality from a DataGrid... Have a DB table of "Contacts" -- 14 or more fields per record Show in datagrid -- but only 5 columns (First,Last,...
1
5281
by: Craig Banks | last post by:
If a row of data in a dataset has a lot of columns the row displaying the data in a datagrid will run way off the screen. What I'd like to do is display a row of data over several datagrid rows so...
1
1248
by: Tom | last post by:
I have seen articles saying that validating the data a user enters into a datagrid is difficult, because it is not the datagrid itself that does the validation, but rather textboxes that are in...
9
3357
by: John Hernry | last post by:
I have been watching the dotnet newsgroups for a couple of weeks now and scouring the net looking for a solution to my datagrid find functionality. With no luck. I am hoping that you can help me....
9
6090
by: Steve | last post by:
How I can remove an AutoGenerated column? I wnat to inlcude the primary key in the resultset for creating some custom LinkButtons, but I don't want it (the PK) displayed in the DataGrid. I tried...
4
3099
by: cooltech77 | last post by:
Hi, I am trying to build the following functionality in the datagrid. I have a lot of columns in the datagrid which are being populated from the database and the user needs to scroll...
0
7111
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7485
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5042
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1542
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.