none
Can't figure out how to delete and edit when these functions are enabled in a grid view RRS feed

  • Question

  • In EW4, I can retrieve selected records with the Where clause, and I can "Enable Edit" and "Enable Delete" in the tag pane. 

    These two words then appear in each record displayed.  If I press either of them, a blank page is returned.

    Code associated with the Edit column for record #9 says "javascript:_doPostBack('Gridview1'; 'Edit$9')"

    How can I make that a hyperlink or in some way invoke code to allow editing or to delete the record?

    Sunday, August 15, 2010 8:31 PM

Answers

  • "How can I make that a hyperlink or in some way invoke code to allow editing or to delete the record?"

    You don't.  That's what the code is supposed to say.

    If you've done things correctly, it should work.

    Is your database configured to "Generate INSERT, UPDATE and DELETE statements"? (Use the Advanced button when you are configuring the datasource).  This option will only be available if you have included the primary key for the record in your selection.

    Regardless, I can't think of what would show a blank page but not give you an error.

    Monday, August 16, 2010 12:45 AM

All replies

  • "How can I make that a hyperlink or in some way invoke code to allow editing or to delete the record?"

    You don't.  That's what the code is supposed to say.

    If you've done things correctly, it should work.

    Is your database configured to "Generate INSERT, UPDATE and DELETE statements"? (Use the Advanced button when you are configuring the datasource).  This option will only be available if you have included the primary key for the record in your selection.

    Regardless, I can't think of what would show a blank page but not give you an error.

    Monday, August 16, 2010 12:45 AM
  • Thanks for the quick response.

    I do have the Insert, Delete and Update code added, although I can't see how it's ever invoked.

    Nevertheless, I have found the Delete button on each row "works", sort of.  When pressed, I still get a blank
    page in my viewer window: however if I go back a page with the browser button (manually) I see no change, BUT
    if I refresh the page, the record has indeed been deleted, so that code apparently works, but provides for no user interface
    or path I can invoke to get anything other than a blank, non-error page.

    Assuming the Edit (Update) code also is somehow functional, I still get the blank page, but no screen that would somehow allow the user to change something in the record, and no apparent path (URL) I can invokke to continue the conversation with the user.

    Logically, to edit a field, the present contents of the field(s) has to be presented to the user in a venue where she can type over or blank out those retrieved contents, and then restore the updated record. 

    Maybe a GridView isn't the correct control to use if I want to change / delete a record?

    I've done hundreds of CRUD actions (create, read, update and delete) actions with FrontPage and Access databases, so
    I'm not a novice at database-driven sites: all my sites are data-driven, actually.  I see nowhere in EW where I can write of generate an UPDATE or DELETE SQL command: everythings a SELECT command.

    THanks again for your quick response.

    Monday, August 16, 2010 4:13 AM
  • I changed to a Details View, and can indeed update a record, but still have to go thru the blank bage and backspace drill, but don't have to refresh the page ???!!!.

    Also, a details view allows mey to only access one record, apparently the first, for a given "Member"

    Monday, August 16, 2010 4:29 AM
  • I can't help you with the blank page issue.  Never happens to me. Edit and Delete work fine in a GridView.
    Monday, August 16, 2010 5:28 AM
  • They "work"  ?

     

    When you click on Edit or Delete, what is the next screen you see and how did you get to it?

    Monday, August 16, 2010 6:32 AM
  • You would normally see the refreshed GridView again, with the row you've deleted removed.

    It's sometimes useful to have a dialog asking the user to confirm deletion. For a way to do this, see the first entry on:

    http://www.ew-resource.co.uk/asp-tips.aspx

     


    Ian Haynes

    EW V4 Add-Ins
    EW resources, hints and tips
    • Edited by Ian Haynes Monday, August 16, 2010 11:04 AM
    Monday, August 16, 2010 11:04 AM
  • Yes, that is how Details View works -- accessing just the one record at a time.

    Please take time to read through the tutorials at:

    http://www.homepagedoctor.com/Tutorials.htm

    They are step-by-step and should show you how to make things work. Also, a really good book that explains each control pretty well, and if possible, I recommend you buy:

    Murach's ASP.NET 3.5 Programming With VB 2008

    It gives code examples too.

    Finally, if your website allows visitors to be entering / modifying data in your database, and if there is any chance of malicious visitors, you will be needing to add validation controls for your textboxes, and when you get to that point, you will discover that the ListView (because it gives you access to the code that lays out everything so you can set up tables the way you want) will be easier to use than the Gridview / Details View combinations.



    ClarkNK, A.K.A. HomePage Doctor
    HomePageDoctor.com -- Expression Web database tutorials
    Ownertrades.com -- Created with FP, Access, Bots and Wizards
    MyNumbersTracker.com -- Created with Expression, VWDExress, SQL Express, and ASP.NET.
    Monday, August 16, 2010 11:11 AM
  • "They "work"  ?"

    Edit posts back with that line editable and "Cancel" or "Update" as action options.

    Delete posts back with that line gone.

    A seamless experience for the user: no blank page, backing up, etc.

     (Have you messed about with the postback?)
    Monday, August 16, 2010 2:01 PM
  • It the "post back" that isn't happening . . . where do you tell it to "post back", assuming that means refresh and redisplay the page?

    I'm using the examples from HomeDoctor word-for-word.

    DOes EW Development Server work properly?

    MY pages don't run at all when I post them to my live site.

    Monday, August 16, 2010 3:21 PM
  • Thanks for the response.

    I' using Homedoctor examples line-for-line.

    "Posting Back", i.e., refreshing the page after delete or allowing the user to edit fields within the record isn't working.

    Is there a place in the tag pane where I need to say "post back" or something similar?

    This was so much easier in FP, even tho I sometimes had to write the SQL myself

    Monday, August 16, 2010 3:27 PM
  • Does your live site webhost support ASP.NET?
    --
    Chris Hanscom - Microsoft MVP
    On Facebook | On Twitter | Resource Center | Veign's Blog | Web Development Help

    Get a Complete Website Analysis by Veign
    Monday, August 16, 2010 3:37 PM
  • "MY pages don't run at all when I post them to my live site."

    Then you better check to see what you did wrong:  Not publish the database?  Not choose a hosting account that runs asp.net 2.0 or higher?  It would be easier to suggest a solution if you explained what you mean by "don't run at all".  What error?  Better yet, post a link so we can see.

    Monday, August 16, 2010 5:53 PM
  • By default, it will postback.  Since I don't know which example you are following, and since I dont' know what your code is, I can't say much more than that.

    And yes, of course the development server will run this.  That's what I use to test basic asp.net sites that don't need anything fancy.

    Monday, August 16, 2010 5:55 PM
  • My pages don't post back.

    Apparently, the Delete functions works, if I manually bring the page back up.

    Is there some tab attribute I have inadvertently invoked that says "Don't post back"

    Monday, August 16, 2010 6:27 PM
  • I have no idea what you have done.  (Not psychic.)

    All I can say is that if your pages are showing code such as you posted in your first message, e.g.:

    "Code associated with the Edit column for record #9 says "javascript:_doPostBack('Gridview1'; 'Edit$9')",

    it sure looks like it's trying to postback.

    In the source of the browser's page, you should see your page name in the <form> tag, e.g.:

    <form method="post" action="gridview.aspx" id="form1">

    and below the Viewstate information you should have a script section something like:

     

    <script type="text/javascript"> 
    //<![CDATA[
    var theForm = document.forms['form1'];
    if (!theForm) {
     theForm = document.form1;
    }
    function __doPostBack(eventTarget, eventArgument) {
     if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
      theForm.__EVENTTARGET.value = eventTarget;
      theForm.__EVENTARGUMENT.value = eventArgument;
      theForm.submit();
     }
    }
    //]]>
    </script>
    


     You haven't mentioned what browsers you have been testing this in.  Do you see any different behavior in a different browser?

    Monday, August 16, 2010 8:48 PM
  • Thanks for hanging in with me . . .

    The (blank) pages I'm getting aren't immaculate conceptions, appearing from nowhere:

    I titled (named) the pages that should be reposting, and they are indeed rendered correctly as the "post-back (????) pages, but they're blank.

      Example: I generate MPDetails.aspx, which includes all the records for a given player (think of it as golf scores, with dates, course name, score and partners for each round played).

      When I then press EDIT or DELETE, I get back a blank page with the same page name, presented to the user. Not an Error page: but not a reposted page with revised content, either: just blank.  That means there's a correct process to re-render the page with revised results, but a breakdown somewhere when it comes to what to present as the revised data, i.e. a deleted record or a revisible record with field(s) for editing.

    In other words, if my original page with EDIT and DELETE links appear for each record, then when I click on either EDIT or DELETE, the same physical page is re-rendered, but it is blank.

    In the case of Delete, although the page is blank, if I manually do BACK in the browser (IE8) and press F5 (refresh) then the record has indeed been Deleted.  Of course I've had no way to communicate this with the user, or indeed any way to continue the process/dialog, such as DELETING or EDITing another rcord.

    Your reward awaits you in Heaven . . .

    Tuesday, August 17, 2010 12:56 AM
  • Again, I'm not psychic.  There is nothing I can do with your verbal description.  It doesn't show me anything.

    Publish the page.  Post a link.

    Tuesday, August 17, 2010 1:24 AM
  • Again, I'm not psychic.  There is nothing I can do with your verbal description.  It doesn't show me anything.
    Publish the page.  Post a link.

    If I had a nickel for every time we've had to say those words, or words to that effect, I could retire tomorrow.

    If I had a quarter for every time they were ignored until we gave up trying to be of assistance, I could retire rich.

    cheers,
    scott


    C'mon, folks. This isn't rocket science, nor neurosurgery. It's "Expression" (singular) "Web" (singular), in that order, followed by a version numeral if you wish to be specific. It is often abbreviated "EW." It is not "Web Expression," "Expressions Web," "Web Expressions," or plain "Expression" or "Expressions." Not using the correct name indicates either ignorance or laziness. Most folks would rather avoid the appearance of either.
    Tuesday, August 17, 2010 3:15 AM
  • THanks for your helpful (?) reply. 

    I guess I'll go back to Front Page.

    Tuesday, August 17, 2010 5:04 AM
  • Publish a blank page. . . . no doubt that would solve the problem.
    Tuesday, August 17, 2010 5:05 AM
  • Hi Bob,

     

    Normally when the 'blank' page using a gridview shows after a post back, it means that the "select" in the database call isn't returning any records and hence, blank page. (I assume there is nothing else on the page, like regular text. If it has, then what I am discussing here probably does not apply.)

    if you are using a "plan vanilla" gridview, in other words, your programming was limited to "drop and drag" of the gridview control, and no separate hand tweaking of the code was done, I think the scenario I have described here is unlikely.

     

    If, on the other hand, you have set some events, such as "on deletion" and then moved the "select call" by hand into this and "page_load" event, this can often cause a blank page if something isn't done just right.

    So to summarize - if you just did a "drop and drag" gridview I have no clue why the blank page, but if you hand tweaked the code it is entirely possible. Post the code and we can take a look at it.

     

     


    rickidoo
    Tuesday, August 17, 2010 11:37 AM
  • "Publish a blank page. . . . no doubt that would solve the problem."

     

    Good grief.  Publish the page, was the request.  It's not blank to start, according to you.  We could then see what the page code contained (when it's blank and when it's not, by the way: blank pages have code in them too) and how it behaved live on the server, including what the code shows before, during, and after your editing/deleting/back-and-forthing.
    Tuesday, August 17, 2010 3:52 PM
  • THanks, Rick for your interest: following is the code for the page that allows for Edit and Delete

    of individual records.  I've touched nothing in the code.

    ==========================================

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ Page Language="C#" %>
    <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">
    <meta content="text/html; charset=windows-1252" http-equiv="Content-Type" />
    <title>MasterPoint Edit</title>
    </head>

    <body style="background-color: #FFFFCC">

    <form id="form1" runat="server">
     <asp:GridView id="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="PointsID" DataSourceID="MPEdit">
      <Columns>
       <asp:CommandField ShowDeleteButton="True" ShowEditButton="True">
       </asp:CommandField>
       <asp:BoundField DataField="PointsID" HeaderText="PointsID" InsertVisible="False" ReadOnly="True" SortExpression="PointsID">
       </asp:BoundField>
       <asp:BoundField DataField="PlayerNo" HeaderText="PlayerNo" SortExpression="PlayerNo">
       </asp:BoundField>
       <asp:BoundField DataField="Points" HeaderText="Points" SortExpression="Points">
       </asp:BoundField>
       <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date">
       </asp:BoundField>
       <asp:BoundField DataField="Club" HeaderText="Club" SortExpression="Club">
       </asp:BoundField>
       <asp:BoundField DataField="Color" HeaderText="Color" SortExpression="Color">
       </asp:BoundField>
       <asp:BoundField DataField="Partner1" HeaderText="Partner1" SortExpression="Partner1">
       </asp:BoundField>
       <asp:BoundField DataField="Partner2" HeaderText="Partner2" SortExpression="Partner2">
       </asp:BoundField>
       <asp:BoundField DataField="Partner3" HeaderText="Partner3" SortExpression="Partner3">
       </asp:BoundField>
       <asp:BoundField DataField="Partner4" HeaderText="Partner4" SortExpression="Partner4">
       </asp:BoundField>
      </Columns>
     </asp:GridView>
     <asp:AccessDataSource ID="MPEdit" runat="server" DataFile="MP2003.mdb" DeleteCommand="DELETE FROM [Points] WHERE [PointsID] = ?" InsertCommand="INSERT INTO [Points] ([PlayerNo], [Points], [Date], [Club], [Color], [Partner1], [Partner2], [Partner3], [Partner4]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)" SelectCommand="SELECT * FROM [Points] WHERE ([PlayerNo] = ?)" UpdateCommand="UPDATE [Points] SET [PlayerNo] = ?, [Points] = ?, [Date] = ?, [Club] = ?, [Color] = ?, [Partner1] = ?, [Partner2] = ?, [Partner3] = ?, [Partner4] = ? WHERE [PointsID] = ?">
      <DeleteParameters>
       <asp:Parameter Name="PointsID" Type="Int32" />
      </DeleteParameters>
      <InsertParameters>
       <asp:Parameter Name="PlayerNo" Type="String" />
       <asp:Parameter Name="Points" Type="Decimal" />
       <asp:Parameter Name="Date" Type="String" />
       <asp:Parameter Name="Club" Type="String" />
       <asp:Parameter Name="Color" Type="String" />
       <asp:Parameter Name="Partner1" Type="String" />
       <asp:Parameter Name="Partner2" Type="String" />
       <asp:Parameter Name="Partner3" Type="String" />
       <asp:Parameter Name="Partner4" Type="String" />
      </InsertParameters>
      <SelectParameters>
       <asp:FormParameter FormField="ACBLNo" Name="PlayerNo" Type="String" />
      </SelectParameters>
      <UpdateParameters>
       <asp:Parameter Name="PlayerNo" Type="String" />
       <asp:Parameter Name="Points" Type="Decimal" />
       <asp:Parameter Name="Date" Type="String" />
       <asp:Parameter Name="Club" Type="String" />
       <asp:Parameter Name="Color" Type="String" />
       <asp:Parameter Name="Partner1" Type="String" />
       <asp:Parameter Name="Partner2" Type="String" />
       <asp:Parameter Name="Partner3" Type="String" />
       <asp:Parameter Name="Partner4" Type="String" />
       <asp:Parameter Name="PointsID" Type="Int32" />
      </UpdateParameters>
     </asp:AccessDataSource>
    </form>

    </body>

    </html>
    ==============================

     

    Tuesday, August 17, 2010 4:07 PM
  • If  Kathy has "answered" anything, it's news to me . . . ."" 

    I sent the code she wanted to see, got NO response, but a claim of answering my problem . . . .

    Pretty much a  waste of my time, with NO ANSWER . . . . and smart remarks about "thinking a little"

    If she wanted to see the code in the failing page, she could have asked for that on the first response. . . .

    Finally Rick asked the intelligent questsion: post the code, which is vanilla from a gridview aspx control

    To repeat: the code submitted did in fact DELETE a record, but still presented a blank page afterward, and I had to manually backpage the browser and refresh (F5), to see the record had actually been deleted.

    I though that's where the thread was: answer provided is simply not true, especially by Kathy.

    Rick: are you still interested in figuring out the bug in EW 4?

    I'd appreciate any advise you have, before I go back to Front Page and do this app in an hour or two.

    Thanks

    Thursday, August 19, 2010 5:19 AM
  • There's no way anyone can tell you what is going wrong on your system.  The code you posted doesn't tell us.

    PUBLISH THE PAGE AND DATABASE.  (How many times do you have to be told to do that?)  I bet you it will work just fine for everyone else, and maybe even you, but if not, someone may be able to see what is wrong.

     

    (Did you even bother to check what I asked you earlier?  If the source for the previewed page had what it was supposed to have?  If a different browser behaved differently for you?  Trying to pin down where the problem was?  Since you never replied to it, probably not.  You seem to think that continuing to repeat what you've already said will make us psychic.)

    Thursday, August 19, 2010 5:41 AM
  • Bob,

    I can't say for sure that this is causing the issue, but it looks like a prime suspect.

    Look at the select statement:

    SelectCommand="SELECT * FROM [Points] WHERE ([PlayerNo] = ?)"

    Then, look at what playerNo is referring to:

     <asp:FormParameter FormField="ACBLNo" Name="PlayerNo" Type="String" />

    Where in the page you sent is the formField ACBLNo?

    If you want to take this conversation off line, go to my website, www.allureiw.com, and email me via the contact page.

     

     

     


    rickidoo
    Thursday, August 19, 2010 10:42 AM
  • Rick,

    If that form field is not actually defined anywhere, the selection will be empty, including initially.  That's not what is being described as happening.  [The posted page may have been edited, and not the complete page being tested - the OP can say.]

    Thursday, August 19, 2010 2:07 PM
  • What do you have about posting a link to the page online, like Kathy had asked?  You're new to the forum, Kathy is not.  We need to see pages in an operational state.  Showing code usually doesn't help because we can't reproduce your issue since we don't have access to the assets required to make your code function.

    You asking for help, someone who answers 1000's of posts is attempting to help and all you are doing is ignoring the request like you know better.

    Back to FP for you...


    --
    Chris Hanscom - Microsoft MVP
    On Facebook | On Twitter | Resource Center | Veign's Blog | Web Development Help

    Get a Complete Website Analysis by Veign
    Thursday, August 19, 2010 2:26 PM
  • I can't post a link to the malfunctioning pages bcause THEY'RE NOT ONLINE. They're in the EW Development Server in my PC
    Thursday, August 19, 2010 6:44 PM
  • Rick, thanks so much for actually looking at the code, thus discovering an apparent flaw.

    Your analysis gives me a clue as to where the problem is, and I will pursue it immediately.

    It's still a mystery to me that the Delete function works, and not the Edit, even though neither reposts the page.

    At any rate, thanks again so much for actually working on my problem

    Thursday, August 19, 2010 7:05 PM
  • Please read the Before Posting post.  To get help, you publish your pages.  Anywhere.  Temporarily.  Of course they are not finished if you are asking for help.
    Thursday, August 19, 2010 9:15 PM