gpt4 book ai didi

c# - 选择按钮 - ASP.NET 中 GridView 上的 CommandField

转载 作者:太空宇宙 更新时间:2023-11-03 22:11:24 26 4
gpt4 key购买 nike

我有下面的代码在网页上创建一个 GridView。我试图禁用 SelectButton 或使其不可见,或者只是删除它。我试过了

AutoGenerateSelectButton="false"

<asp:CommandField SelectText="Seç" Visible="false"
ShowSelectButton="True" />

我什至删除了这部分

<Columns>
<asp:CommandField SelectText="Seç" ShowSelectButton="True" />
</Columns>

它们都不起作用,SelectButton 仍然存在。我试图用

将它的 SelecText 更改为
<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();
}

我只想要一个没有 SelectButtonGridView

最佳答案

删除特定行的选择:

在 RowDatBound 中

e.Row.Cells[0].Controls[0].Visible = false;

关于c# - 选择按钮 - ASP.NET 中 GridView 上的 CommandField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6492629/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com