How to Add "Quick Add" button to grid row

2 posts, 0 answers
  1. Corey
    Corey avatar
    3 posts
    Member since:
    Feb 2013

    Posted 05 May 2014 Link to this post

    I am trying to add a button the the user can click on that will grab values from the row and then add to the cart. I would like this to confirm with the radwindow or radalert so the user is not taken to a new page and they can add items quickly.  How do I do this?

    Currently I have it setup to where a the code-behind will go through each row and look at the qty field and then add the rows that have a qty > 0  

    For Each dataitem As GridDataItem In RadGrid1.Items
              If DirectCast(dataitem.FindControl("qtytxt"), TextBox).Text > "" Then
                  Try
                      Dim UOM As DropDownList = DirectCast(dataitem.FindControl("UOM_DDL"), DropDownList)
                      Dim qty As String = DirectCast(dataitem.FindControl("qtytxt"), TextBox).Text
                      Dim item As GridDataItem = TryCast(dataitem, GridDataItem)
                      Dim item_id As String = RTrim(item("item_id").Text)
                      Dim FindForm As FormView = CType(dataitem.FindControl("FormView3"), FormView)
                      Dim UnitPrice As Label = CType(FindForm.FindControl("Unit_Price"), Label)
                      Dim linecount As String = GetLineCount()
     
                       
                      nCMD.CommandText = "*****************"
                      nConn.Open()
                      nCMD.ExecuteNonQuery()
                      nConn.Close()
                  Catch ex As Exception
                      Session("error") = ex.ToString()
                      Response.Redirect("Cart.aspx?error=" & ex.ToString)
                  End Try
     
     
              End If
          Next
  2. Corey
    Corey avatar
    3 posts
    Member since:
    Feb 2013

    Posted 05 May 2014 in reply to Corey Link to this post

    I figured out how to do this.

    In my aspx page i added this button to my row.
     <telerik:RadButton ID="RadButton1" runat="server" Text="RadButton" CommandName="QuickAdd"></telerik:RadButton>

    and then in the code behind i did this.
    Protected Sub RadGrid1_ItemCommand(sender As Object, e As GridCommandEventArgs) Handles RadGrid1.ItemCommand
           If e.CommandName = "QuickAdd" Then
     
               Dim UOM As DropDownList = DirectCast(e.Item.FindControl("UOM_DDL"), DropDownList)
               Dim qty As String = DirectCast(e.Item.FindControl("qtytxt"), TextBox).Text
               Dim item As GridDataItem = TryCast(e.Item, GridDataItem)
               Dim item_id As String = RTrim(item("item_id").Text)
               Dim FindForm As FormView = CType(e.Item.FindControl("FormView3"), FormView)
               Dim UnitPrice As Label = CType(FindForm.FindControl("Unit_Price"), Label)
               Dim linecount As String = GetLineCount()
    nCMD.CommandText = "******"
    nConn.Open()
               nCMD.ExecuteNonQuery()
               nConn.Close()
     
     
               n2.Text = "Item has been added to cart" + "<br/>" + item_id + "<br/><a href=cart.aspx>Click here to goto cart page</a>"
               n2.Show()


    so far this seems to work.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top