locked
RepeaterCommandEventArgs RRS feed

  • Question

  • User477931538 posted

    Hello,

       I'm not sure if the problem I'm having is on the VB side or on the call from the ASP side, so please forgive me if I've guessed wrong. I'm stumped. I'v been putting togeather some forums, and at this point in my development I'm adding an edit function. Problem is, I keep getting the error

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '<'.

    Source Error:

    Line 88:                 Dim Cmdsub2 As New SqlCommand(strSQL, MyConn2)
    Line 89:                 MyConn2.Open()
    Line 90:                 objDR = Cmdsub2.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
    Line 91:                 If objDR.Read() Then
    Line 92:                     postTXTBX.Text = objDR("msg_content")

    Here's my code: Calling line in ASP

    <asp:ImageButton ID="editIMGBTN" runat="server" ImageUrl="~/graphics/parts-web/freebuttons.com/HubloMedDa0.gif" Visible='<%# getvisible(eval("msg_id_user"))%>' CommandName="myedit" CommandArgument='<%Eval("msg_id")%>'/>

    And the VB sub

    Protected Sub post_edit(ByVal source As Object, ByVal e As RepeaterCommandEventArgs)

       If Not IsNothing(Session("trail")) Then

          If e.CommandName = "myedit" Then

             Dim StrConnection As String = (System.Configuration.ConfigurationManager.AppSettings("DBconnect"))

             Dim strSQL As String = "select msg_content from msg_msgs where msg_id = " & e.CommandArgument

             Dim MyConn2 As New SqlConnection(StrConnection)

             Dim objDR As SqlDataReader

             Dim Cmdsub2 As New SqlCommand(strSQL, MyConn2)

             MyConn2.Open()

             objDR = Cmdsub2.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

             If objDR.Read() Then

                postTXTBX.Text = objDR("msg_content")

             End If

            MyConn2.Close()

             postBTN.Visible = "false"

             postchangeBTN.Visible = "True"

          End If

       Else

          Response.Redirect("./Not_logged_in.aspx")

       End If

    End Sub

    Saturday, May 17, 2008 4:01 PM

Answers

  • User1873438307 posted

    Hello,

    First of all do this

    CommandArgument='<%#Eval("msg_id")%>'/>

    Then make sure that the msg_id is numeric

     

    Regards 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 17, 2008 5:42 PM

All replies

  • User1873438307 posted

    Hello,

    First of all do this

    CommandArgument='<%#Eval("msg_id")%>'/>

    Then make sure that the msg_id is numeric

     

    Regards 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 17, 2008 5:42 PM
  • User477931538 posted

    You are completely right, that worked like a charm.

    Please tell me, do you have any good links I can read up on the EVAL command from? 2 ASP books, 2 VB.NET books, and a SQL book and I'm still fumbling around trying to find a real explanation for using it. For instance I think I've seen someone use <%$ Eval... instead of <%# Eval... but I don't know the difference. I'd happily read any documents you send me to for it. The site I'm working on right now is just a project I made up so I could have something to learn from, and unfortunatly all the books I'm getting are more enthused with all th new stuff in 3.5 than in covering some of the more basic things I need. Thanks for the help you've already given me, and in advance for any pointers you send me to.

    Saturday, May 17, 2008 6:29 PM
  • User1873438307 posted

    The hash sign was used to indicate data binding. :) 

    Saturday, May 17, 2008 7:48 PM