This is a migrated thread and some comments may be shown as answers.

How to Add "Quick Add" button to grid row

1 Answer 53 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Corey
Top achievements
Rank 1
Corey asked on 05 May 2014, 01:37 PM
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

1 Answer, 1 is accepted

Sort by
0
Corey
Top achievements
Rank 1
answered on 05 May 2014, 02:08 PM
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.
Tags
Grid
Asked by
Corey
Top achievements
Rank 1
Answers by
Corey
Top achievements
Rank 1
Share this question
or