使用C#
的GridView
<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中使用&#34; e&#34;
if (e.Item.ItemType == ListItemType.Item)
{
}
答案 0 :(得分:1)
GridView
没有ItemDataBound
个事件。那是DataGrid
事件。它使用RowDataBound
代替。 RowDataBound
类似,但您必须指定要更改的行中的哪个控件:
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lbl = (Label)e.Row.FindControl("ID");
string ID = lbl.Text;
}