Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / October 2004

Tip: Looking for answers? Try searching our database.

Move Datagrid Row Up/Down

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael Murphy - 22 Oct 2004 21:05 GMT
Hi,
Anyone have suggestions for how to select a row in a web datagrid and either
drag and drop it somewhere else in the grid or use up/down arrows to move
the row to the desired location?
Any feedback would be appreciated.
Thanks,
Michael Murphy
mdmurphy@scs-techresources.com
954-452-1047
Eliyahu Goldin - 24 Oct 2004 09:36 GMT
Similar question was discussed here recently. Google the usergroups for
thread "client side sorting of datagrid items".

Eliyahu

> Hi,
> Anyone have suggestions for how to select a row in a web datagrid and either
[quoted text clipped - 5 lines]
> mdmurphy@scs-techresources.com
> 954-452-1047
Steven Cheng[MSFT] - 25 Oct 2004 04:06 GMT
Hi Michael,

As Eliyahu mentioned, there're some former threads dicussing on such
questions. Generaly, since the asp.net datagrid is a serverside databound
template control which generate all the columns and rows via the datasource
bind to it, so the normal way to change the datagrid row's order is to
change the datasource bind to it. If you only want to change the datagrid's
display rows at clientside, we need to use some clientside scripts( such as
the DHTML behaviors ) mentioned in some other threads:

http://groups.google.com/groups?hl=en&lr=&threadm=umFJl%239rEHA.3848%40TK2MS
FTNGP14.phx.gbl&rnum=1&prev=/groups%3Fq%3D%2522client%2Bside%2Bsorting%2Bof%
2Bdatagrid%2Bitems%2522%26hl%3Den

Also, here are some tech article links which demonstrate how to use
clientside DTHML behavior to alert the HTML TABLE element or asp.net
datagrid control at clientside via dhtml behaviors;

http://msdn.microsoft.com/msdnmag/issues/04/01/CuttingEdge/default.aspx

http://www.microsoft.com/mind/0499/HTMLbehaviors/HTMLbehaviors.asp

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Michael D Murphy - 25 Oct 2004 15:16 GMT
Steve,
Let's say I have the following grid characteristics:

Slot    Name    Other Info    Details
1      Mike        38 Years     LinkToDetailsRecord
2       Joe           41 Years    LinkToDetailsRecord
3        Bob        23 Years    LinkToDetailsRecord

Now Slot is not in the detail records, it is basicall a sort column used by
another process. What I want here, is for the administrator to be able to
move Bob to slot 2 where joe is and then joe would be slot 3. In other
words, select a row and be able to move it up one or down one,with the slot
numbers staying the same.
Hope this helps you understand what I need to do.
Michael
> Hi Michael,
>
[quoted text clipped - 31 lines]
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
Steven Cheng[MSFT] - 26 Oct 2004 08:28 GMT
Hi Michael,

Thanks for your response and the further description. Based on your
requirement, I think it is very complex to implement such task via
clientside script(need very advanced javascript technique and time for
debugging). Also, when the page is post back,the clientside changes may not
reflect to the serverside datas. So my suggestion is when the datas
(records) first retrieved from database, we maintain it in a local
DataTable which stored in the page's viewstate or sessionstate. And when
the Administrator want to move rows up or down, just locate that certain
datarow in the stored datatable and adjust its position in the datatable
(switch with another row in the table) and rebind the table with the
datagrid again.  
But this need the page to postback to serverside whenever the admin need to
do such changes on the grid.

Please let me know if you have any other concerns. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Michael D Murphy - 28 Oct 2004 15:01 GMT
Hi Steve,

Just to refresh your memory, this is what I put in the last posting:

Let's say I have the following grid characteristics:

Slot    Name    Other Info    Details                               HiddenField
1      Mike        38 Years     LinkToDetailRecord          PrimaryKeyToDetailRecord
2       Joe           41 Years    LinkToDetailRecord          PrimaryKeyToDetailRecord
3        Bob        23 Years    LinkToDetailRecord           PrimaryKeyToDetailRecord

Further Info.
Slot is in the records for this dataset (tblAdsToRun)-just not in the detail records (tblAdvertisements). Slot is basically a column used by
the display ad process. What I want here, is for the administrator to be able to
move the Bob record to slot 2 where record Joe is and then record Joe would be slot 3. In other
words, select a row and be able to move it up one or down one, with the slot
numbers staying the same.

Now I have tried something different things and different approaches.. In the GridUpdate event I allow the user to change the Slot and upon update I need to write the database record back to the tblAdsToRun table. For me to get to the right row, I need the PrimaryKey (a hidden field in the grid). For some reason, I cannot get that number from the grid. It just keeps showing up as blank (""). Do you think I have something else going on here, or is it a fact that if the field is visible=false then you cannot access the hidden data. I am sure I have done this before. Any suggestions?
Thanks for your help!

Michael


Michael D. Murphy
     Senior Software Architect
SCS Tech Resources, Inc.
1400 Northwest 70 Way, Suite HO1
Plantation, FL 33313-5330
mdmurphy@scs-techresources.com
954-452-1047

> Hi Michael,
>
[quoted text clipped - 22 lines]
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
Michael D Murphy - 28 Oct 2004 20:20 GMT
Steve,
After banging my head against the wall for two days, I figured that I need to change the edited field (Slot) to a template field and use the FindControl method to retrieve the value. At this point all is well with the way that I am doing it. Maybe it is not the best way, but it works.
Thanks for your help.
Michael
 Hi Steve,

 Just to refresh your memory, this is what I put in the last posting:

 Let's say I have the following grid characteristics:

 Slot    Name    Other Info    Details                               HiddenField
 1      Mike        38 Years     LinkToDetailRecord          PrimaryKeyToDetailRecord
 2       Joe           41 Years    LinkToDetailRecord          PrimaryKeyToDetailRecord
 3        Bob        23 Years    LinkToDetailRecord           PrimaryKeyToDetailRecord

 Further Info.
 Slot is in the records for this dataset (tblAdsToRun)-just not in the detail records (tblAdvertisements). Slot is basically a column used by
 the display ad process. What I want here, is for the administrator to be able to
 move the Bob record to slot 2 where record Joe is and then record Joe would be slot 3. In other
 words, select a row and be able to move it up one or down one, with the slot
 numbers staying the same.

 Now I have tried something different things and different approaches.. In the GridUpdate event I allow the user to change the Slot and upon update I need to write the database record back to the tblAdsToRun table. For me to get to the right row, I need the PrimaryKey (a hidden field in the grid). For some reason, I cannot get that number from the grid. It just keeps showing up as blank (""). Do you think I have something else going on here, or is it a fact that if the field is visible=false then you cannot access the hidden data. I am sure I have done this before. Any suggestions?
 Thanks for your help!

 Michael

 
 Michael D. Murphy
       Senior Software Architect
 SCS Tech Resources, Inc.
 1400 Northwest 70 Way, Suite HO1
 Plantation, FL 33313-5330
 mdmurphy@scs-techresources.com
 954-452-1047
 
 "Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message news:Sbt541yuEHA.2092@cpmsftngxa10.phx.gbl...
 > Hi Michael,
 >
 > Thanks for your response and the further description. Based on your
 > requirement, I think it is very complex to implement such task via
 > clientside script(need very advanced javascript technique and time for
 > debugging). Also, when the page is post back,the clientside changes may not
 > reflect to the serverside datas. So my suggestion is when the datas
 > (records) first retrieved from database, we maintain it in a local
 > DataTable which stored in the page's viewstate or sessionstate. And when
 > the Administrator want to move rows up or down, just locate that certain
 > datarow in the stored datatable and adjust its position in the datatable
 > (switch with another row in the table) and rebind the table with the
 > datagrid again.  
 > But this need the page to postback to serverside whenever the admin need to
 > do such changes on the grid.
 >
 > Please let me know if you have any other concerns. Thanks.
 >
 > Regards,
 >
 > Steven Cheng
 > Microsoft Online Support
 >
 > Get Secure! www.microsoft.com/security
 > (This posting is provided "AS IS", with no warranties, and confers no
 > rights.)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.