如何将每行的 ListView TextBox 项目写入数据库
How to write ListView TextBox Items to Database for each row
我有这个列表视图:
<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 数据库?
提前致谢
你可以试试这个,没有机会测试是否找到控件。
List<ListViewDataItem> lItems = fundingListView.Items.ToList();
foreach(ListViewDataItem item in lItems)
{
TextBox tb = item.FindControl("fundingConfirmationAmount") as TextBox;
string addToDatabase = tt.Text;
}
我有这个列表视图:
<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 数据库?
提前致谢
你可以试试这个,没有机会测试是否找到控件。
List<ListViewDataItem> lItems = fundingListView.Items.ToList();
foreach(ListViewDataItem item in lItems)
{
TextBox tb = item.FindControl("fundingConfirmationAmount") as TextBox;
string addToDatabase = tt.Text;
}