|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataGrid Functionality Questionssome 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 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, Show quoteHide quote "Phillip N Rounds" <prou***@cassandragroup.com> wrote in message news:uZVntmMMGHA.2604@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 > 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 Show quoteHide quote "Terry Burns" <m*@mine.com> wrote in message news:e66WztNMGHA.3496@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" <prou***@cassandragroup.com> wrote in message > news:uZVntmMMGHA.2604@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 >> > > 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. Show quoteHide quote "Phillip N Rounds" <prou***@cassandragroup.com> wrote in message news:OMbRyUPMGHA.3144@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" <m*@mine.com> wrote in message > news:e66WztNMGHA.3496@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" <prou***@cassandragroup.com> wrote in message >> news:uZVntmMMGHA.2604@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 >>> >> >> > >
radiobuttonlist.selectedIndex always -1.........
Checkbox in datagrid.... How to read value of a dynamically created radiobuttonlist control? Checkbox state after postback Trying to set stored procedure parameter for sqldatasource in formview (edit mode) asp.net control to run in web page like just COM refresh gridview asp:Repeater + no viewstate + DataBind() ?? Where are the events of the aspx? Looking for graphic control to use in .NET |
|||||||||||||||||||||||