首页 > 解决方案 > 更改使用面板显示的代码生成的按钮样式

问题描述

这是我用于在 asp.net 中生成分页按钮的代码,但想更改按钮的样式以匹配 Bootstrap 分页类的样式。由于按钮是从后面的代码生成的,我怎么能这样做?这是 C# 背后的代码:

private void AddpagingButton()
        {
            // this method for generate custom button for Custom paging in Gridview
            int totalRecord = 0;
            int noofRecord = 0;
            totalRecord = ViewState["TotalRecord"] != null ? (int)ViewState["TotalRecord"] : 0;
            noofRecord = ViewState["NoOfRecord"] != null ? (int)ViewState["NoOfRecord"] : 0;
            int pages = 0;
            if (totalRecord >0 && noofRecord > 0)
            {
                // Count no of pages 
                pages = (totalRecord / noofRecord) + ((totalRecord % noofRecord) > 0 ? 1 : 0);
                for (int i = 0; i < pages; i++)
                {
                    Button b = new Button();
                    b.Text = (i + 1).ToString();
                    b.CommandArgument = (i + 1).ToString();
                    b.ID = "Button_" + (i + 1).ToString();
                    b.Click += new EventHandler(this.b_click);
                    Panel1.Controls.Add(b);
                }
            }

        }

这是前端的简单面板组件:

<asp:Panel ID="Panel1" runat="server"></asp:Panel>

标签: c#asp.nettwitter-bootstrappaginationpaging

解决方案


推荐阅读