我的问题是在ASP.NET GridView控件上。我在列标记中使用CommandField,如下所示。
<asp:CommandField ShowEditButton="True" HeaderStyle-Width="40px" UpdateText="Save" ButtonType="Link" HeaderStyle-Wrap="true" ItemStyle-Wrap="true" ItemStyle-Width="40px"/>呈现在以下图像中的是什么(在我单击编辑按钮之后)。

正如您可以看到的,,我正在尝试让Cancel链接显示一个新的行,我的问题是您如何做?,如果我将ButtonType="Link"更改为ButtonType="Button",我将它正确地呈现如下所示。
alt文本http://i38.tinypic.com/2pqopxi.jpg
我已经试过谷歌了,也许我没有在正确的标签上搜索,但我之前看不到这个地址。
发布于 2008-10-09 18:53:01
如果使用模板字段,它将使您完全控制页面的外观,但它要求您使用CommandName和可能的CommandArgument属性,还需要使用GridView的OnRowCommand。
aspx页面:
<asp:GridView id="gvGrid" runat="server" OnRowCommand="gvGrid_Command">
<Columns>
<asp:TemplateField>
<ItemTemplate>
Some Stuff random content
<br />
<asp:LinkButton id="lbDoIt" runat="server" CommandName="Cancel" CommandArgument="SomeIdentifierIfNecessary" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>背后的代码:
protected void gvGrid_Command(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName=="Cancel")
{
// Do your cancel stuff here.
}}
发布于 2008-10-09 17:37:18
不要使用命令字段,使用TemplateField并将命令按钮与行中断(br)放在其中。
https://stackoverflow.com/questions/188327
复制相似问题