c# - What in the Repeater -
an issue has manifested in particular area of page i'm working on utilizes infamous repeater. command bound valid data source persist through view state.
the repeater code follows:
<asp:repeater id="creditrightitems" runat="server" datasourceid="sdsorder"> <headertemplate> <thead> <td>qty returning:</td> <td>price:</td> </thead> </headertemplate> <itemtemplate> <tr> <td><asp:textbox id="txtquantity" runat="server" placeholder="0" cssclass="txtquantity credit-check" data-item='<%# eval("productnum") %>' /><span class="creditx">x</span></td> <td><span id="productprice" class='credit-container price<%# eval("productnum") %>'><%# converttomoney(eval("price").tostring()) %></span> <input type="hidden" id="hfprice" value="<%# eval("price") %>" /> <input type="hidden" id="hfprodnum" value="<%# eval("productnum") %>" /> <input type="hidden" id="hfsku" value="<%# eval("sku") %>" /> </td> </tr> </itemtemplate> </asp:repeater>
the issue occurs in code behind when iterate through repeater. loop finds 2 controls, may apart of issue. however, when effort grab values code-behind homecoming null
. if add together runat="server"
error repeater.
foreach (repeateritem item in creditrightitems.items) { textbox inputquantity = (textbox)item.findcontrol("txtquantity"); string quantity = inputquantity.text; textbox inputproduct = (textbox)item.findcontrol("hfprodnum"); string product = inputproduct.text; htmlinputhidden productprice = (htmlinputhidden)item.findcontrol("hfprice"); string cost = productprice.value; textbox inputsku = (textbox)item.findcontrol("hfsku"); string sku = inputsku.text; if (string.compare(quantity, "0") != 0 && string.isnullorempty(quantity)) items.add(new items(product, quantity, price, sku)); }
the question is, how can valid value for:
productprice
or hfprice
hfprodnum
hfsku
for life of me can't them homecoming valid content. i've tried:
hiddenfield productprice = (hiddenfield).item.findcontrol("hfprice"); string cost = productprice.value; htmlinputhidden productprice = (htmlinputhidden).item.findcontrol("hfprice"); string cost = productprice.value;
i know findcontrol
requires runat
i'm trying either accomplish way avoid repeater
breaking when add together runat
or way grab contents of inputs
.
any thoughts , help terrific.
what have in source aren't server controls, findcontrol won't find them.
why can't convert hidden fields asp:hiddenfield tags?
<asp:hiddenfield id='hfprice' value='<%# eval("price") %>' runat='server' />
the runat isn't breaking page; think it's single vs double quotes on eval call. if alternate them have in sample, work.
c# asp.net
No comments:
Post a Comment