how to change datalist's bind fied by codebehind code?
-
Generally,we can control datalist's display field by databinding in html,such as <%# Container.DataItem("Title") %> Now i have a problem,I want to change this bind field by my option in codebehind file,such as i want to display Title+Digest or Column+Title so who can tell me how to make this done? Thanks in advance! I'm terribly troubled by this problem and looking forward to your reply.
-
Generally,we can control datalist's display field by databinding in html,such as <%# Container.DataItem("Title") %> Now i have a problem,I want to change this bind field by my option in codebehind file,such as i want to display Title+Digest or Column+Title so who can tell me how to make this done? Thanks in advance! I'm terribly troubled by this problem and looking forward to your reply.
Hi BGBE, You can put togethere multiple fields right there in the ASPX, such as:
<%# Container.DataItem("Title") + " " + Container.DataItem("Digest") %>
Or if you prefer codebehind, you can access the cell during the DataList's ItemDataBound event, and change the cell contents there. Marcie http://www.codeproject.com
-
Hi BGBE, You can put togethere multiple fields right there in the ASPX, such as:
<%# Container.DataItem("Title") + " " + Container.DataItem("Digest") %>
Or if you prefer codebehind, you can access the cell during the DataList's ItemDataBound event, and change the cell contents there. Marcie http://www.codeproject.com
Thank you for your reply. I want to dynamically created different template,not statically. Now i have solved my problem. I define a datalist in html with ItemTemplate be null,then create serval user control for template,then load them with my different option. Thanks!;P