Solved

FormView - After update goes to wrong record

Posted on 2006-07-21
9
240 Views
Last Modified: 2008-02-01
I've run into this problem a few times, I update something in the FormView that is in the Order By clause of the SQL in the SqlDataAdapter, thus changing the order of the rows.  Then the form view goes to ReadOnly mode at the same index as before the edit, but the record displayed is now whatever is in that spot after the order changed.

Any way to force it to go to the record with the same datakeyname after update?
0
Comment
Question by:whityum
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
9 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17160864
I don't understand the situation that you have described.

Bob
0
 
LVL 7

Author Comment

by:whityum
ID: 17163338
I am trying to find a way to loop through the rows of data and find the right key, and then just set the index to that, but I can't figure it out without loading the data into a datatable with another connection and looping through that.  you'd think you could just set the selected data key.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17163584
Can you show me what you have tried that doesn't work, please?

Bob
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 7

Author Comment

by:whityum
ID: 17167024
I've tried what i've done in the past for other controls, loop through the dataitems or set the datasource equal to the datasource of another dataset or something, but it doesn't have the same properties and methods as other controls
0
 
LVL 7

Author Comment

by:whityum
ID: 17167225
Oh, I missed the don't, I thought you did understand.

I have a formview that is bound to a SqlDataSource, all of the edit, insert, and view code is on the ASPX page and built into the 2 controls, there are SqlParameters in the SqlDataSource that do all of the updating by passing the variables to stored procedures, I haven't written any code.

say it's connected to a datasource with 3 records and it's ordered alphabetically by a column, the records are A, C, and E.

A
C
E

I go into edit mode, and change record C to Z, now the order is

A
E
Z

When you come out of edit mode back to readonly mode it is now showing record E because it seems to go back to the same item index of the formview instead of the same record
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17191433
I have no idea.

Bob
0
 
LVL 7

Author Comment

by:whityum
ID: 17391160
this was my work around if wants to know.

Int32 featureItemID = Convert.ToInt32(e.CommandArgument.ToString());
                  this.featureTypeID = Convert.ToInt32(e.CommandName.ToString());
                  int featureIndex = 0;
                  divReport.Visible = false;
                  sdsFeature.SelectParameters["active"].DefaultValue = "False";
                  sdsFeature.SelectParameters["featureTypeID"].DefaultValue = featureTypeID.ToString();
                  sdsFeature.DataBind();
                  fvFeature.DataBind();
                  DataSourceSelectArguments args = new DataSourceSelectArguments();

                  DataView dv = (DataView)sdsFeature.Select(args);

                  DataTable dt = dv.ToTable();            

                  for(int x = 0; x < dt.Rows.Count; x++){
                        if (dt.Rows[x]["featureItemID"].ToString() == featureItemID.ToString()) {
                              featureIndex = x;
                              break;
                        }                  
                  }

                  fvFeature.PageIndex = featureIndex;            
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 17575775
PAQed with points refunded (500)

CetusMOD
Community Support Moderator
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question