【发布时间】:2011-06-27 12:09:37
【问题描述】:
我有以下代码在网页上创建 GridView。我正在尝试禁用 SelectButton 或使其不可见,或者只是删除它。我试过了
AutoGenerateSelectButton="false"
和
<asp:CommandField SelectText="Seç" Visible="false"
ShowSelectButton="True" />
我什至删除了这部分
<Columns>
<asp:CommandField SelectText="Seç" ShowSelectButton="True" />
</Columns>
它们都不起作用,SelectButton 仍然存在。 我试图用
将它的SelecText 更改为 Aç
<asp:CommandField SelectText="Aç" ShowSelectButton="True" />
这也不好用。我也试过了
ShowSelectButton="False" and it didn't change anything.
<asp:UpdatePanel ID="UpdatePanelEnCokSatilanUrunler" runat="server">
<ContentTemplate>
<asp:Panel ID="PanelEnCokSatilanUrunler" runat="server"
GroupingText="En Çok Satılan Ürünler"
BorderWidth="1" Font-Bold="true">
<table class="style1">
<tr>
<td>
<asp:GridView ID="GridView_EnCokSatilanUrunler"
runat="server"
OnRowDataBound="GridView_EnCokSatilanUrunler_RowDataBound"
Font-Bold="false"
OnSelectedIndexChanged="GridView_EnCokSatilanUrunler_SelectedIndexChanged"
AllowSorting="true"
OnSorting="GridView_EnCokSatilanUrunler_Sorting">
<Columns>
<asp:CommandField SelectText="Seç"
ShowSelectButton="True"/>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
这是我在 aspx.cs 中的内容,它对 SelectButton 没有任何作用
protected void GridView_EnCokSatilanUrunler_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void GridView_EnCokSatilanUrunler_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
((LinkButton)e.Row.Cells[1].Controls[0]).Text = "Ürün No";
((LinkButton)e.Row.Cells[2].Controls[0]).Text = "Ürün Adı";
((LinkButton)e.Row.Cells[3].Controls[0]).Text = "Satış Miktarı";
((LinkButton)e.Row.Cells[4].Controls[0]).Text = "Ürün Durum";
((LinkButton)e.Row.Cells[5].Controls[0]).Text = "Ürün Tipi";
((LinkButton)e.Row.Cells[6].Controls[0]).Text = "Marka";
((LinkButton)e.Row.Cells[7].Controls[0]).Text = "Model";
}
else if (e.Row.RowType == DataControlRowType.DataRow)
{
}
}
protected void GridView_EnCokSatilanUrunler_Sorting(object sender, GridViewSortEventArgs e)
{
if (EnCokSatilanUrunlerSortColumn == e.SortExpression)
{
if (EnCokSatilanUrunlerSortDirection)
EnCokSatilanUrunlerSortDirection = false;
else if (!EnCokSatilanUrunlerSortDirection)
EnCokSatilanUrunlerSortDirection = true;
}
else
EnCokSatilanUrunlerSortDirection = true;
EnCokSatilanUrunlerSortColumn = e.SortExpression;
EnCokSatilanUrunlerPageIndex = 0;
GridView_EnCokSatilanUrunler.SelectedIndex = -1;
}
void EnCokSatilanUrunlerGridDoldur()
{
GridView_EnCokSatilanUrunler.DataSource = DAL.raporx.DAOUrunx.GetEnCokSatilanBesUrun(
DateTime.Now - new TimeSpan(30, 0, 0, 0),
DateTime.Now
);
GridView_EnCokSatilanUrunler.DataBind();
}
我只想要一个没有SelectButton 的GridView。
【问题讨论】:
-
建议添加一个模板字段,并放置一个链接按钮,上面写着“选择”
-
@deostroll 感谢 deostroll 先生,但我不希望选择按钮甚至不是链接按钮。