如何在c#中使用itembounound
本文关键字:itembounound | 更新日期: 2023-09-27 18:08:27
使用c#
显示数据表格
<asp:Panel ID="DetailsPanel" runat="server" Width="100%" Height="100%" Visible="false">
<asp:GridView
ID="gridViewDetails"
CssClass="GridView"
runat="server"
AllowPaging="True"
AllowSorting="true"
AutoGenerateColumns="false"
DataKeyNames="employee#"
PageSize=25
title=""
Width="98%"
>
<Columns>
<asp:BoundField
DataField="employee#"
HeaderText="Employee"
HeaderStyle-HorizontalAlign="Center"
ItemStyle-HorizontalAlign="Left"
ItemStyle-Width="15%"/>
<asp:BoundField
DataField="pay_start_date"
HeaderText="Pay Start Date"
HeaderStyle-HorizontalAlign="Center"
ItemStyle-HorizontalAlign="Left"
ItemStyle-Width="8%"/>
<asp:BoundField
DataField="pay_end_date"
HeaderText="Pay End Date"
HeaderStyle-HorizontalAlign="Center"
ItemStyle-HorizontalAlign="Left"
ItemStyle-Width="8%"/>
<asp:BoundField
DataField="income_var"
HeaderText="Variable Income"
HeaderStyle-HorizontalAlign="Center"
ItemStyle-HorizontalAlign="Right"
ItemStyle-Width="8%"/>
<asp:TemplateField ItemStyle-HorizontalAlign="right" HeaderText="File Status">
<ItemTemplate>
<div>
<a id="lnkshowhide" runat="server">
<asp:LinkButton ID="lnkEdit" Text="Edit" CommandName="Edit" CommandArgument='<%# Eval("employee#") %>' runat="server"></asp:LinkButton>
<asp:Image ID="imgplus" runat="server" ImageUrl="~/Images/plusIcon.gif" /></a>
</div>
<tr id="trDesc" runat="server">
<td colspan="10" id="tddesc" runat="server" style="border-bottom-color: Black; border-bottom-width: 1px;">
<b>Response -- </b>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle CssClass="gridRow"/>
<FooterStyle CssClass="gridFooter"/>
<PagerStyle CssClass="gridPager"/>
<SelectedRowStyle CssClass="gridSelectedRow"/>
<EditRowStyle CssClass="gridEditRow"/>
<AlternatingRowStyle CssClass="gridAlternativeRow"/>
</asp:GridView>
</asp:Panel>
在c#中,我找不到ItemDataBound事件,我只能找到RowDataBound
我想使用下面的代码在ItemDataBound,如果我使用在RowDataBound得到错误在"e"
if (e.Item.ItemType == ListItemType.Item)
{
}
GridView
没有ItemDataBound
事件。这是DataGrid
事件。它使用RowDataBound
代替。RowDataBound
是类似的,但您必须指定要更改的行中的哪个控件:
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lbl = (Label)e.Row.FindControl("ID");
string ID = lbl.Text;
}