-
19-02-2013, 03:43 PM #1Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
Thêm thuộc tính css cho 1 linkbutton trong Repeater như thế nào ?
Mình dùng repeater để làm phân trang. Code như sau :
Mã:<asp:Repeater ID="phanTrang" runat="server" onitemcommand="phanTrang_ItemCommand"> <ItemTemplate> <li><asp:LinkButton ID="gotoPage" CommandName="page" CommandArgument="<%# Container.DataItem%>" runat="server" ><%# Container.DataItem%></asp:LinkButton></li> </ItemTemplate> </asp:Repeater>
Nhưg mình làm hoài vẫn k đc, mình dùng FindControl("gotoPage") mà sao nó cứ báo null hoài [IMG]images/smilies/21.gif[/IMG]
Đây là code
Mã:protected void phanTrang_ItemCommand(object source, RepeaterCommandEventArgs e) { CurrentPage = Convert.ToInt32(e.CommandArgument) -1; //Response.Write((e.Item.ItemIndex).ToString()); for (int i = 0; i < pg.PageCount; i++) { LinkButton idPage = phanTrang.Items[i].FindControl("gotoPage") as LinkButton; if (idPage != null) idPage.Attributes.Add("class", "active"); else Response.Write("Khong the add CSS"); }
View more random threads:
- Video hướng dẫn tạo Website với WebMAtrix ( Tool làm web cực kool miễn phí của MS )
- Cách kết nối và thao tác với SQL Server trong ASP.NET?
- Cách truy vấn quan hệ nhiều - nhiều trong Entity Framework
- đính kèm file javascript khi biên dịch file dll
- Làm sao đổi màu và bỏ dấu gạch chân dưới hyperlink
- lỗi A potentially dangerous Request.Form value was detected from the client file web.config khi đã up lên host?
- Giải pháp nào cho tìm kiếm trong dữ liệu lớn?
- Cách load lại trang web theo đúng vùng dữ liệu đang đọc
- làm sao để tạo được 1 thanh cuộn lên xuống trong datalist
- Làm sao load lại dữ liệu bằng ajax nhưng không dùng control UpdatePanel
-
19-02-2013, 06:08 PM #2Administrator
- Ngày tham gia
- Feb 2014
- Bài viết
- 0
cách 1:
đổi cái này
Mã:LinkButton idPage = phanTrang.Items[i].FindControl("gotoPage") as LinkButton;
Mã:LinkButton idPage = phanTrang.FindControl("gotoPage") as LinkButton;
Mã:if(e.CommandName == "page"){ // do something in here.....}
Ngọc Bích xanh bản chất thuộc dòng đá đá hoa (jade). Và cẩm thạch là tên gọi chung của ngọc bích. Vì thực chất chúng thuộc dòng đá đa khoáng được hình thành từ chất Silicat dưới dạng dioxy. Ngọc bích...
Chia sẻ Vòng tay ngọc bích xanh là...