我有这个Listview:
<asp:ListView ID="fundingListView" runat="server" OnItemCommand="fundingListView_OnItemCommand" OnItemDataBound="fundingListView_OnItemDataBound" DataKeyNames="ID">
<ItemTemplate>
<div style="width:40px; float:left; margin:5px 15px 5px 0px; padding-left:10px;">
<asp:LinkButton ID="addFundingLinkButton" runat="Server" ToolTip="Finanzierung zuweisen" CommandName="addFunding" CssClass="insertTextModuleButtonFade"></asp:LinkButton>
</div>
<div style="float:left; width:40px; margin:10px 10px 5px 0px; text-align:center;"><%# Eval("id") %> </div>
<div style="float:left; width:120px; margin:10px 10px 5px 0px; text-align:center;"><%# Eval("financialPartnerId") %> </div>
<div style="float:left; width:80px; margin:10px 10px 5px 0px; text-align:center;"><%# Eval("accountNumber") %> </div>
<div style="float:left; width:120px; margin:10px 10px 5px 0px; text-align:center;"><%# Eval("fundingAmount") %></div>
<div style="float:left; width:120px; margin-left:40px;">
<asp:TextBox ID="fundingConfirmationAmount" runat="server" Width="96" Height="12"></asp:TextBox>
</div>
<asp:Label id="fundingAlreadyAddedButton" runat="server" style="visibility:hidden"><%# Eval("alreadyAdded") %></asp:Label>
<div class="clear"></div>
</ItemTemplate>
可以在网页上更改文本框“fundingConfirmationAmount”的值。
如何在列表视图的每一行中访问此文本框中输入的值,并将新文本写入我的mysql数据库?
提前致谢
答案 0 :(得分:2)
你可以尝试这个,没有机会测试是否找到了控件。
List<ListViewDataItem> lItems = fundingListView.Items.ToList();
foreach(ListViewDataItem item in lItems)
{
TextBox tb = item.FindControl("fundingConfirmationAmount") as TextBox;
string addToDatabase = tt.Text;
}