TAILIEUCHUNG - Professional ASP.NET 1.0 Special Edition- P11
Professional Special Edition- P11:Those of us who are Microsoft developers can't help but notice that .NET has received a fair amount of visibility over the last year or so. This is quite surprising considering that for most of this period, .NET has been in its early infancy and beta versions. I can't remember any unreleased product that has caused this much interest among developers. And that's really an important point, because ignoring all the hype and press, .NET really is a product for developers, providing a great foundation for building all types of applications | ASP Repeater id MyRepeater runat server ItemTemplate br ItemTemplate ASP Repeater p b lt ASP DataList gt b control br ASP DataList id MyDataList runat server ItemTemplate - value Value 0 E ItemTemplate ASP DataList p b lt ASP CheckBoxList gt b control br ASP CheckBoxList id MyCheckList runat server p b lt ASP RadioButtonList gt b control br ASP RadioButtonList id MyRadioList runat server p The declaration of the HTML select ASP DropDownList and ASP ListBox controls at the top of the page and the ASP CheckBoxList and ASP RadioButtonList controls at the bottom of the page is no different to the previous example - we just define the control itself. However the definition of the other three list controls has to take into account the new structure of the data source. Binding a DataGrid Control To a HashTable The DataGrid control cannot figure out by itself how to handle a HashTable and needs us to provide some help. As you ll see in more detail later in this chapter we do this by setting the AutoGenerateColumns property of the control to False and then using a Columns element and ASP BoundColumn controls to specify where the values should come from. The two columns are bound to the Key and Value fields in each item using the following syntax. We also specify a DataFormatString for the Value column so that it is displayed in currency format ASP DataGrid id MyDataGrid runat server AutoGenerateColumns false Columns ASP BoundColumn HeaderText Key DataField Key ASP BoundColumn HeaderText Value DataField Value DataFormatString 0 C Columns ASP DataGrid Binding a Repeater and a DataList Control To a HashTable The Repeater and the DataList controls contain an ItemTemplate entry as in the previous example where we used an ArrayList. However now we can include two values in each template - the Key property and the Value property. We refer to these as properties of the .
đang nạp các trang xem trước