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

RadAjaxPanel cannot access html table in C#

1 Answer 68 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 12 Jun 2014, 05:27 PM
I have a RadAjaxPanel that contains a table I am trying to update through the C# code. What happens is the user will first buy all the items, and click "Confirm Purchase". The original panel will go invisible, and then the final radajaxpanel will become visible. At that point, a method in C# will be called to populate the table inside with the final cart. However, in my C# code, when I try to add a newly created row to the table, I get an error that the table doesn't exist. Here's the code: <telerik:RadAjaxPanel ID="PanelCompletePurchase" runat="server" Visible="false">
    <h4>Complete Purchase</h4> 
    <table id="ReceiptTable">
        <tr>
           <th>Quantity</th>
           <th>Product</th>
           <th>Rate</th>
           <th>Price</th>
        </tr>
    </table>
    <asp:Label ID="Message" runat="server" ForeColor="Maroon"></asp:Label>
                <br />
                <asp:Label ID="Response" runat="server" ForeColor="maroon"></asp:Label>
                <br />
                <asp:Label ID="Debug" runat="server" forecolor="maroon"></asp:Label>
</telerik:RadAjaxPanel>

In my C# code, I doReceiptTable.Rows.Add(someCreatedRow);ReceiptTable is red and it shows unknown entity. How do I access the html table inside of the RadAjaxPanel? My Labels update just fine





1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 13 Jun 2014, 06:23 AM
Hi Jason,

Please have a look into the sample code snippet which adds a row in the table on button click.

ASPX:
<telerik:RadAjaxPanel ID="PanelCompletePurchase" runat="server" Visible="true">
    <telerik:RadButton ID="Rad
Button1"
runat="server" Text="Add Row" OnClick="RadButton1_Click">
    </telerik:RadButton>
    <h4>
        Complete Purchase</h4>
    <table id="ReceiptTable" runat="server">
        <tr>
            <td>
                Quantity
            </td>
            <td>
                Product
            </td>
            <td>
                Rate
            </td>
            <td>
                Price
            </td>
        </tr>
    </table>
    <asp:Label ID="Message" runat="server" ForeColor="Maroon"></asp:Label>
    <br />
    <asp:Label ID="Response" runat="server" ForeColor="maroon"></asp:Label>
    <br />
    <asp:Label ID="Debug" runat="server" ForeColor="maroon"></asp:Label>
</telerik:RadAjaxPanel>

C#:
protected void RadButton1_Click(object sender, EventArgs e)
{
    HtmlTableRow tRow = new HtmlTableRow();
    HtmlTableCell cell1 = new HtmlTableCell();
    cell1.InnerText = "10";
    tRow.Cells.Add(cell1);
    HtmlTableCell cell2 = new HtmlTableCell();
    cell2.InnerText = "Pen";
    tRow.Cells.Add(cell2);
    HtmlTableCell cell3 = new HtmlTableCell();
    cell3.InnerText = "5";
    tRow.Cells.Add(cell3);
    HtmlTableCell cell4 = new HtmlTableCell();
    cell4.InnerText = "2";
    tRow.Cells.Add(cell4);
    ReceiptTable.Rows.Add(tRow);
}

Thanks,
Princy.
Tags
General Discussions
Asked by
Jason
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or