简体   繁体   English

我需要编辑和更新转发器值

[英]I need to Edit and update the repeater values

I have a repeater that has five column (ITEM,ITEM DESCRIPTION,PRICE ,QUANTITY AND TOTAL).I am binding the values to repeater from database table for the columns ITEM,ITEM DESCRIPTION AND QUANTITY and Two columns ( PRICE AND TOTAL) are felt blank because this has to be filled by the user.How can i achieve this(it may have many rows) ? 我有一个具有五列的转发器(项目,项目描述,价格,数量和总计)。我将值绑定到数据库表中针对项目,项目描述和数量的列的转发器,并且感觉到两列(价格和总计)空白,因为这必须由用户填写。我如何实现这一点(它可能有很多行)?

This my repeater code: 这是我的中继器代码:

<div id="RPT">
                                    <table cellpadding="0" cellspacing="0">
                                        <asp:Repeater ID="Repeater1" runat="server" OnItemCommand="RptrAtchmnt_ItemCommand"
                                            OnItemDataBound="RptrAtchmnt_ItemDatabound">
                                            <HeaderTemplate>
                                                <tr>
                                                    <th colspan=".5">
                                                        S.NO
                                                    </th>
                                                    <th>
                                                        ITEM
                                                    </th>
                                                    <th colspan="4">
                                                        ITEM DESCRIPTION
                                                    </th>
                                                    <th>
                                                        PRICE
                                                    </th>
                                                    <th>
                                                        QUANTITY
                                                    </th>
                                                    <th>
                                                        TOTAL
                                                    </th>
                                                    <th>
                                                        DELETE
                                                    </th>
                                                </tr>
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="lblSINo" runat="server" Text='<%# Eval("sino")%>'></asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblITEM" runat="server" Text='<%# Eval("ITEM")%>'></asp:Label>
                                                    </td>
                                                    <td colspan="4">
                                                        <asp:Label ID="lblEXTENSION" runat="server" Text='<%# Eval("DES")%>'></asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblPRICE" runat="server" Text='<%# Eval("PRI")%>'></asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblqty" runat="server" Text='<%# Eval("QTY")%>'></asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblTOTAL" runat="server" Text='<%# Eval("TOT")%>'></asp:Label>
                                                    </td>
                                                    <td id="RptrAtchRemve" runat="server">
                                                        <asp:Button ID="lnkRemove" runat="server" CssClass="btn red" CommandName="Remove"
                                                            CausesValidation="false" DataKeyNames="sino" Text="Remove" Width="90px" Height="37px"
                                                            CommandArgument='<%# Eval("sino")%>' />
                                                    </td>
                                                </tr>
                                            </ItemTemplate>
                                        </asp:Repeater>
                                        <tr id="FileUploadRow" runat="server">
                                            <td colspan="1">
                                            </td>
                                            <td colspan="1">
                                                <asp:TextBox ID="txt_item" placeholder="ENTER ITEM " runat="server"></asp:TextBox>
                                            </td>
                                            <td colspan="4">
                                                <asp:TextBox ID="txt_itemdes" placeholder="ENTER ITEM DESCRIPTION  " runat="server"></asp:TextBox>
                                            </td>
                                            <td colspan="1">
                                                <asp:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="txt_PRI"
                                                    FilterType="Numbers">
                                                </asp:FilteredTextBoxExtender>
                                                <asp:TextBox ID="txt_PRI" placeholder="ENTER ITEM PRICE" runat="server"></asp:TextBox>
                                            </td>
                                            <td colspan="1">
                                                <asp:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server" TargetControlID="txt_qty"
                                                    FilterType="Numbers">
                                                </asp:FilteredTextBoxExtender>
                                                <asp:TextBox ID="txt_qty" placeholder="ENTER ITEM QUANTITY" runat="server"></asp:TextBox>
                                            </td>
                                            <td>
                                            </td>
                                            <td colspan="1">
                                                <asp:Button ID="Button1" Text="Add" CssClass="btn green" OnClientClick="btnUpload"
                                                    runat="server" Width="90px" Height="37px" OnClick="btn1_Click" />
                                            </td>
                                        </tr>
                                    </table>
                                </div>

This C# code : 此C#代码:

 #region "REPEATER TO TEMP TABLE"
protected void btn1_Click(object sender, EventArgs e)
{


    string ITEM = txt_item.Text;
    string ITEM_DES = txt_itemdes.Text;
    string ITEM_QTY = txt_qty.Text;
    string ITEM_PRICE = txt_PRI.Text;
    int ITEM_TOTAL = Convert.ToInt32(txt_PRI.Text) * Convert.ToInt32(txt_qty.Text);
    BindRptr(ITEM_QTY, ITEM, ITEM_DES, ITEM_PRICE, ITEM_TOTAL);
    txt_item.Text = "";
    txt_itemdes.Text = "";
    txt_qty.Text = "";
    txt_PRI.Text = "";

}
#endregion


#region LoadItem
public void LoaditmRptr(string QUOT_ID)
{
    using (logsystemDataContext db_rept = new logsystemDataContext())
    {
        var _item = (from itm in db_rept.quotation_items
                     where itm.quotation_id.Equals(QUOT_ID)
                     select new
                     {
                         itm.item,
                         itm.item_des,
                         itm.qty,
                         itm.price,
                         itm.total_price,
                     }).ToList();

        if (_item.Count != 0)
        {

            int count;
            TempTable = DataColumn();
            foreach (var itm in _item)
            {
                count = TempTable.Rows.Count + 1;
                DataRow dr = TempTable.NewRow();
                dr["sino"] = count;
                dr["QTY"] = itm.qty;
                dr["ITEM"] = itm.item;
                dr["DES"] = itm.item_des;
                dr["PRI"] = itm.price;
                dr["TOT"] = itm.total_price;
                TempTable.Rows.Add(dr);
                ViewState["TempTable"] = TempTable;
            }
            Repeater1.DataSource = TempTable;
            Repeater1.DataBind();

        }
        else
            LoadEmptyReptrAttachment();
    }
}
#endregion


public DataTable DataColumn()
{
    TempTable.Clear();
    TempTable.Columns.Add("sino");
    TempTable.Columns.Add("QTY");
    TempTable.Columns.Add("ITEM");
    TempTable.Columns.Add("DES");
    TempTable.Columns.Add("PRI");
    TempTable.Columns.Add("TOT");
    TempTable.PrimaryKey = new DataColumn[] { TempTable.Columns["sino"] };
    return TempTable;
}
#endregion

PLEASE HELP IT NEED TO DONE IMMM.... 请帮助完成IMMM。

In your code sample, both price and total are labels, I suppose at least on them them will be changed to a textbox later and that you want to do retrieve the value and do the calculation on the server side. 在您的代码示例中,价格和总计都是标签,我想至少它们之后将它们更改为文本框,并且您要在服务器端检索值并进行计算。
Upon pushback, loop through the items of the repeater. 推回时,遍历转发器的项目。 Be aware that not only content items but also the header and footer items are enumerated, so you might want to check for the type of the item. 请注意,不仅枚举了内容项,而且还枚举了页眉和页脚项,因此您可能需要检查项的类型。 For the items on question, you can use FindControl along with the control id to access a specific control in the item. 对于有问题的项目,可以将FindControl与控件ID一起使用以访问该项目中的特定控件。 This way, you can retrieve or change values in the item. 这样,您可以检索或更改项目中的值。 You also apply this technique later when storing data into the database. 稍后在将数据存储到数据库中时,也可以应用此技术。
There are plenty of examples ( 1 , 2 ) for this on the web, so I won't provide a code sample. 有大量的例子( 12 )这种情况的网络上,所以将不提供一个代码示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM