Link to home
Start Free TrialLog in
Avatar of Seven price
Seven priceFlag for United States of America

asked on

edit delete programatically

r.CssClass = "prgdata"
            c = New TableCell
            c.Text = "<input type=submit  value=Edit&nbsp;Quantity />"
            r.Cells.Add(c)

            r.CssClass = "prgdata"
            c = New TableCell
            c.Text = "<input type=submit  value=Delete />"
            r.Cells.Add(c)

Visual studio 2003 1.1 frameworks

Yes I am not to sure on how to have a functional edit update and delete button programatically.
When I choose edit the Quantity should become a textbox and then I will update. Binded no problem, programatically a problem.

Dim sqlDR As SqlDataReader
        conn.Open()
        sqlDR = cmd.ExecuteReader(CommandBehavior.Default)
       
 
        ' While sqlDR.Read
        r = New TableRow
        r.CssClass = "HeaderCell"
        r.Style.Add("background", "339300")
        r.Style.Add("color", "FFFFFF")
        ' r.Style.Add("color", "Black")
        c = New TableCell
        c.ColumnSpan = 5
 
        c = New TableCell
        c.Text = "UPC code"
        r.Cells.Add(c)
 
        c = New TableCell
        c.Text = "Product Name"
        r.Cells.Add(c)
 
        c = New TableCell
        c.Text = "Quantity"
        r.Cells.Add(c)
 
        c = New TableCell
        c.Text = "Subtotal"
        r.Cells.Add(c)
 
        c = New TableCell
        'c.Text = "Case"
        r.Cells.Add(c)
 
        c = New TableCell
        'c.Text = "pallet"
        r.Cells.Add(c)
 
        'c = New TableCell
        'c.Text = "Trailer"
        'r.Cells.Add(c)
 
        Table1.Rows.Add(r)
        ' End While
 
 
        While sqlDR.Read
 
           
            r = New TableRow
            c = New TableCell
 
            r.CssClass = "prgdata"
            c = New TableCell
            c.Text = sqlDR("myItem")
            r.Cells.Add(c)
 
            r.CssClass = "prgdata"
            c = New TableCell
            c.Text = sqlDR("Name")
            r.Cells.Add(c)
            Table1.Rows.Add(r)
 
            r.CssClass = "prgdata"
            c = New TableCell
            c.Text = sqlDR("Quantity")
            r.Cells.Add(c)
 
            r.CssClass = "prgdata"
            c = New TableCell
            c.Text = FormatPrice778(sqlDR("SubTotal"))
            r.Cells.Add(c)
 
            r.CssClass = "prgdata"
            c = New TableCell
            c.Text = "<input type=submit  value=Edit&nbsp;Quantity />"
            r.Cells.Add(c)
 
            r.CssClass = "prgdata"
            c = New TableCell
            c.Text = "<input type=submit  value=Delete />"
            r.Cells.Add(c)
 
            r.CssClass = "prgdata"
            c = New TableCell
            c.Text = "&nbsp;"
            r.Cells.Add(c)
 
           
            
            If sqlDR("BalanceQty") = "0" Then
 
                c.Text = "&nbsp;"
 
            Else
              
                Table1.Rows.Add(r)
                r = New TableRow
                c.Text = "&nbsp;"
                r.Cells.Add(c)
 
                c = New TableCell
                c.Text = "Cases"
                r.Cells.Add(c)
 
                r.CssClass = "prgdata2"
                c = New TableCell
                c.Text = sqlDR("BalanceQty")
                r.Cells.Add(c)
 
                r.CssClass = "prgdata2"
                c = New TableCell
                c.Text = FormatPrice778(sqlDR("CaseCost"))
                r.Cells.Add(c)
 
                r.CssClass = "prgdata2"
                c = New TableCell
                c.Text = "&nbsp;"
                r.Cells.Add(c)
 
            End If
 
            If sqlDR("TotalPalletQty") = "0" Then
 
                c.Text = "&nbsp;"
 
            Else
                Table1.Rows.Add(r)
                r = New TableRow
                c.Text = "&nbsp;"
                r.Cells.Add(c)
 
                c = New TableCell
                c.Text = "Pallet"
                r.Cells.Add(c)
 
                r.CssClass = "prgdata2"
                c = New TableCell
                c.Text = sqlDR("TotalPalletQty")
                r.Cells.Add(c)
 
                r.CssClass = "prgdata2"
                c = New TableCell
                c.Text = FormatPrice778(sqlDR("PalletCost"))
                r.Cells.Add(c)
 
                r.CssClass = "prgdata2"
                c = New TableCell
                c.Text = "&nbsp;" 'FormatPrice778(sqlDR("PalletCost"))
                r.Cells.Add(c)
 
            End If
 
 
            If sqlDR("TotalTrailerQty") = "0" Then
                c.Text = "&nbsp;"
            Else
                Table1.Rows.Add(r)
                r = New TableRow
                c.Text = "&nbsp;"
                r.Cells.Add(c)
 
                c = New TableCell
                c.Text = "Trailer"
                r.Cells.Add(c)
 
                r.CssClass = "prgdata2"
                c = New TableCell
                c.Text = sqlDR("TotalTrailerQty")
                r.Cells.Add(c)
 
                r.CssClass = "prgdata2"
                c = New TableCell
                c.Text = FormatPrice778(sqlDR("Trailer"))
                r.Cells.Add(c)
            End If
            Table1.Rows.Add(r)
 
           
 
        End While

Open in new window

Avatar of Jeeva Subburaj
Jeeva Subburaj
Flag of United States of America image

instead of adding each row in the buttion, you could use DATAGRID control and bind the data source along with the button..

you can use BoundColumn property for binding these values and use Template Column for adding button..

this links helps u to understand the core functionality of datagrid
http://www.codersource.net/asp_net_datagrid_part1_azam.html
Avatar of Seven price

ASKER

Yes I know how to do that, I said that in my comment above, Thats why i was asking to do it programatically because I had no choice.
somthing like i have below.

 r.CssClass = "prgdata"
            c = New TableCell
            selectcol.ButtonType = ButtonColumnType.PushButton
            selectcol.Text = "Update"
            selectcol.CommandName = "Update"
            r.Cells.Add(c)
            'Table1.Rows.Add(selectcol)
            ' DataGrid1.Columns.Add(selectcol)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of AsishRaj
AsishRaj
Flag of Fiji image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial