?
Solved

edit delete programatically

Posted on 2009-03-31
4
Medium Priority
?
328 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:Seven price
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Expert Comment

by:vavjeeva
ID: 24031628
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
0
 
LVL 9

Author Comment

by:Seven price
ID: 24031764
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.
0
 
LVL 9

Author Comment

by:Seven price
ID: 24032517
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

0
 
LVL 9

Accepted Solution

by:
AsishRaj earned 2000 total points
ID: 24035005
How about this

<%@ Page Language="C#" %>
<script runat="server">
    
 
    void btn_Click(object sender, EventArgs e)
    {
                 Response.Write(((sender)as Button).Text);
    }
 
    protected void Page_Load(object sender, EventArgs e)
    {
      HtmlTable myTable = new HtmlTable();
        for (int i = 0; i < 4; i++)
        {
                HtmlTableRow row = new HtmlTableRow();
                HtmlTableCell cell1 = new HtmlTableCell();
                cell1.InnerText = "cell" + i;
                row.Controls.Add(cell1);
                HtmlTableCell cell2 = new HtmlTableCell();
                Button btn = new Button();
                btn.Text = "value" + i;
                btn.Click += new EventHandler(btn_Click);
                cell2.Controls.Add(btn);
                row.Controls.Add(cell2);
                myTable.Controls.Add(row);
            
        }
        PlaceHolder1.Controls.Add(myTable);
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>untitled</title>
</head>
<body  >
    <form id="form1" runat="server" name="someForm" >
    <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
   
    </form>
</body>
</html>

Open in new window

0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
The canonical version of this article is on my web site here: http://iconoun.com/articles/collisions/ A companion presentation is available here: http://iconoun.com/articles/collisions/Unicode_Presentation.pdf
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question