[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

FormView - After update goes to wrong record

Posted on 2006-07-21
9
Medium Priority
?
247 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
  • 4
  • 3
8 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

834 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