我有一个中继器,它有五列(项目、项目描述、价格、数量和总计)。我将值绑定到数据库表中项目、项目描述和数量列的转发器,并且感觉到两列(价格和总计)空白,因为这必须由用户填写。我怎样才能实现这一点(它可能有很多行)?
这是我的中继器代码:
<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>
这个 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
请帮助它需要完成 IMMM....