选择按钮 - CommandField中在ASP.NET的GridView [英] Select Button - CommandField on a GridView in ASP.NET

查看:691
本文介绍了选择按钮 - CommandField中在ASP.NET的GridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这种低于code创建一个webpage.I的GridView我试图禁用SelectButton或使其不可见,或者只是删除它。我试过

I have this below code to create a GridView on a webpage.I am trying to disable the SelectButton or make it invisible, or just delete it.I tried

AutoGenerateSelectButton="false"

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

我甚至删除了这部分

I even deleted this part

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

他们没有工作,在SelectButton仍然存在。
我试图改变它的 SelecText AC

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

和这个没有工作,因为well.I也试过

And this didn't work as well.I also tried

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

This is what I have in aspx.cs, which doesn't do anything with the 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();
        }

我只想要一个 GridView控件没有 SelectButton

推荐答案

只要你不需要 SelectButton 尝试从列部分,并删除 OnSelectedIndexChanged GridView控件声明>和删除 GridView_EnCokSatilanUrunler_SelectedIndexChanged 从code后面的方法。

as long as you don't need the SelectButton try to remove it from Columns section and remove OnSelectedIndexChanged from your GridView declaration and delete GridView_EnCokSatilanUrunler_SelectedIndexChanged method from code behind.

这篇关于选择按钮 - CommandField中在ASP.NET的GridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆