c# - 更改使用面板显示的代码生成的按钮样式
问题描述
这是我用于在 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>
解决方案
推荐阅读
- android - 将地图划分到不同的区域Android Studio?
- c# - 如何在月历 C# 中手动设置特定的开始日期
- c# - 我想使用正则表达式从这个字符串 GRN/GSI/2017/7 中提取 7
- django - 使用 travis 编码环境变量的 Django 和 travis CI 密钥错误
- php - 在php中将1.5的值四舍五入到1?
- asp.net-mvc - 从表单 MVC 中获取价值
- python - 更有效地执行嵌套 python 循环
- postgresql - 如何接受 postgresql 中的任何日期?
- css - 如何使用 Angular 4 及以上版本的 webpack.config 将 sass 与编译集成到 css 中?
- amazon-web-services - 如何排除某些 AWS S3 存储桶文件