Ben
Ben

Reputation: 4319

How do I access the cell content of a pure html table from asp.net

I have a table:

<table id="trTable" runat="server" clientidmode="Static">
        <thead>
            <tr>
                <th style="display:none">
                    ID
                </th>
                <th style="width: 112px">
                    Item
                </th>
                <th style="width: 40px; text-align: left">
                    Price
                </th>
                <th style="width: 24px; text-align: center">
                </th>
                <th style="width: 26px; text-align: center">
                    Qty
                </th>
                <th style="width: 24px; text-align: center">
                </th>
                <th style="width: 40px; text-align: right">
                    Total
                </th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>

and new rows are added to it with jQuery:

var newRow = $("<tr> <td class='drinkID' style='display:none'>" + drinkID + "</td> <td class='drinkName'>" + dName + "</td>  <td class='drinkPrice'>" + dPrice + "</td>  <td style='text-align:center'><input id='Button' type='button' value='<' class='minusButton' /> </td>  <td class='drinkQty'>1</td>  <td style='text-align:center'><input id='Button' type='button' value='>' class=\"plusButton\" /></td>  <td class='drinkTotal'>" + dPrice + "</td>  </tr>");

How do I access the content of the cells using asp.net?

I am using:

foreach (HtmlTableRow row in trTable.Rows)
        {
            Response.Write("RowDetails:" + row.Cells[1].InnerHtml);
        }

But the response.write just outputs:

RowDetails: Item

How come it doesn't get the cell contents?

Upvotes: 3

Views: 2410

Answers (2)

Deep Chandra Panda
Deep Chandra Panda

Reputation: 1

You can also use Microsoft Ajax enabling partial rendering on in the row. This will do the same postback effect but will only send the afffected content to the client side.

Upvotes: 0

Aristos
Aristos

Reputation: 66641

What you change on the html struct page, on client side, is not send back on the server, and sever know nothing about.

With other words, what is on the page, is not fully sanded back on the server.

To solve this, you can make at the same time two edits, one on what user see and one hidden on a hidden input, to post back to the server the changes and recreate the table on the server side.

Hope this make scene.

Upvotes: 2

Related Questions