Question

I want to check with you can I create a new row based on my current table template? I already check the other questions, all of them create new row based on creating all the columns again. I want to check can we make it dynamic?

I remembered in C# or Java we could create a empty row from current table (Or maybe Grid) then we use to add that column to the table and fill it but I cannot remember how or in which language it was!

Kindly please help me with how I can create add a new row to my table and remove a row from my table? I prefer to create my new row based on TableRow template that has been shared.

I want to write some code like below:

datarow dr = TblRFADetails.newrow;
TblRFADetails.add(dr);

Something as above. Please help me. I am using Asp.net v2.

<asp:Table ID="TblRFADetails" runat="server">
    <asp:TableHeaderRow>
        <asp:TableHeaderCell>Ticket No</asp:TableHeaderCell>
        <asp:TableHeaderCell>Ref No</asp:TableHeaderCell>
        <asp:TableHeaderCell>Information onTicket*</asp:TableHeaderCell>
        <asp:TableHeaderCell>Relevant</asp:TableHeaderCell>
        <asp:TableHeaderCell>Region</asp:TableHeaderCell>
        <asp:TableHeaderCell>RFA Remarks</asp:TableHeaderCell>
        <asp:TableHeaderCell>Classification</asp:TableHeaderCell>
    </asp:TableHeaderRow>
    <asp:TableRow>
        <asp:TableCell><asp:TextBox ID="RFA_NO" runat="server" /></asp:TableCell>
        <asp:TableCell><asp:TextBox ID="CUST_REF_NO" runat="server" /></asp:TableCell>
        <asp:TableCell><asp:TextBox ID="FIX_DESCRIPTION" runat="server" /></asp:TableCell>
        <asp:TableCell><asp:DropDownList ID="CLASSIFICATION" runat="server" /></asp:TableCell>
        <asp:TableCell><asp:DropDownList ID="REGION" runat="server" /></asp:TableCell>
        <asp:TableCell><asp:TextBox ID="REMARKS" runat="server" /></asp:TableCell>
        <asp:TableCell><asp:DropDownList ID="PROBLEM_CATEGORY" runat="server" /></asp:TableCell>
   </asp:TableRow>
</asp:Table>
Was it helpful?

Solution

Use a Repeater. You have to fill items into the Repeater and then bind them as the datasource. However, if you just want to create the rows dynamically, simply add a list of IDs or whatever to the Repeater. Then do your dynamic stuff in the ItemDataBound event.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top