Solved

FormView - After update goes to wrong record

Posted on 2006-07-21
9
234 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
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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now