我已经阅读了数十篇关于这个问题的帖子并尝试了所有但没有运气,我不确定我错过了什么是 gridview 代码:
<asp:GridView ID="recentJobsGridView" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None" Height="151px" Width="541px" Visible="False" AutoGenerateColumns="False"
PageSize="5" AllowPaging="True" OnPageIndexChanging="recentJobsGridView_PageIndexChanging"
DataKeyNames="orderItemId">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField HeaderText="Order Date" Visible="true">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("orderItemId") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Order Date">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("orderDate") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="QTY">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("QTY") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ID">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Length">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("length") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="wall">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("wall") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Paper Composition">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("paperComposition") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="btAdd" runat="server" OnCommand="btAdd_Command" Text="Add"
CommandArgument='<%# Container.DataItem %>' CommandName="Add"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
这是我绑定网格视图的地方:
protected void custGridView_SelectedIndexChanged(object sender, EventArgs e)
{
if (custGridView.SelectedDataKey != null)
{
selectCustomer = (int)custGridView.SelectedDataKey.Value;
recentJobsGridView.Visible = true;
recentJobsGridView.DataSource = ViewDataSource(selectCustomer);
recentJobsGridView.DataBind();
}
}
这是LinkButton的代码:
protected void btAdd_Command(object sender, CommandEventArgs e)
{
if (e.CommandName == "Add")
{
StatusLbl.Text = "Hellooooooo";
}
}
我删除了我只想显示此消息的所有内容,但没有响应请帮助...