tailieunhanh - ASP.NET 2.0 Everyday Apps For Dumies 2006 phần 9
Tham khảo tài liệu ' everyday apps for dumies 2006 phần 9', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 10 Building a Web Forum 347 EventArgs e string con WebConfigurationManager 5 .ConnectionStrings ForumConnectionString .Connectionstring ds new DataSet 6 fill the Forums table 7 string sel SELECT forumid name FROM Forums ORDER BY name SqlDataAdapter da new SqlDataAdapter sel con ds Forums fill the Topics table 8 sel SELECT forumid topicid name description FROM Topics ORDER bY name da new SqlDataAdapter sel con ds Topics bind the Forum repeater 9 Forums .Defaultview public void ForumRepeater_ItemDataBound 10 Object sender RepeaterltemEventArgs e Repeater r Repeater 11 .FindControl TopicRepeater DataRowView drv 12 DataRowView string forumid drv forumid .ToString DataView dv 13 Topics .DefaultView forumid forumid dv 14 348 Part V Building Community Applications Here s a set of 14 explanations matched to the 14 key lines of this listing 1 The code-behind file needs access to the . Configuration namespace because it uses the WebConfigurationManager class to retrieve the database connection string from the file. 2 The namespace is required to use classes such as DataSet SqlConnection and SqlCommand. 3 This line defines a class instance variable of type DataSet. That way the dataset will be available to both of the methods in the code-behind file. 4 The Page_Load method executes when the page loads. It fills the dataset with data retrieved from the Forums and Topics tables it also sets up data binding for the ForumRepeater control and calls that control s DataBind method which completes the binding. 5 This line retrieves the connection string from the file. 6 This statement creates an empty dataset object and assigns it to the ds variable. 7 These lines create a table in the ds dataset named Forums by a creating a data
đang nạp các trang xem trước