By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,996 Members | 1,487 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,996 IT Pros & Developers. It's quick & easy.

Question about Data Binding...

P: n/a
Hi there,

I found this question in Amit Kalani's preparation book for exam 70-15 (Developing Web Applications with C#). I think it's a very stupid question! It says the correct answer is A but the explanation is not useful. Please spend sometime reviewing this question and its answer.

Any guide on this matter would be greatly appreciated.

Question: Your Web form includes a DropDownList control named ddlStudent that displays a list of students and a DataGrid control named dgCourses that displays the courses that the selected student is enrolled in. When the page is loaded, you run code that includes the lines:

// Load the data
DataBind();

When the user selects an entry in the DropDownList control, you create a DataView object and then set the DataSource property of the DataGrid control to the DataView object. You're receiving an error at page load. What is the most likely cause of this error?

A. The DataBind() method for the page is attempting to bind data to the DataGrid control as well as to the DropDownList control, and the data for the DataGrid control does not exist yet.

B. The DropDownList control is marked as readonly.

C. There is no student information in the database.

D. The DataBind() method cannot be called in the Page_Load() event handler because no data is available to the form in that event.

Answer: A. Calling the DataBind() method for the page will call the DataBind() method for every control on the page as well, whether the data is available or not.

Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
That's not a stupid question - it tests your knowledge on parent/child controls ... as for me I never use the Page (Me) Databind for this very reason .. I like to have control over what gets bound and when ... the tooltip help for the Databind explicitly says it will bind the current control and all it's child controls ... handy if you have need of it in a smaller scope such as a datagrid with template columns and child controls ...

"Moshfegh Hamedani" <mo******@hamedani.com> wrote in message news:O4**************@TK2MSFTNGP09.phx.gbl...
Hi there,

I found this question in Amit Kalani's preparation book for exam 70-15 (Developing Web Applications with C#). I think it's a very stupid question! It says the correct answer is A but the explanation is not useful. Please spend sometime reviewing this question and its answer.

Any guide on this matter would be greatly appreciated.

Question: Your Web form includes a DropDownList control named ddlStudent that displays a list of students and a DataGrid control named dgCourses that displays the courses that the selected student is enrolled in. When the page is loaded, you run code that includes the lines:

// Load the data
DataBind();

When the user selects an entry in the DropDownList control, you create a DataView object and then set the DataSource property of the DataGrid control to the DataView object. You're receiving an error at page load. What is the most likely cause of this error?

A. The DataBind() method for the page is attempting to bind data to the DataGrid control as well as to the DropDownList control, and the data for the DataGrid control does not exist yet.

B. The DropDownList control is marked as readonly.

C. There is no student information in the database.

D. The DataBind() method cannot be called in the Page_Load() event handler because no data is available to the form in that event.

Answer: A. Calling the DataBind() method for the page will call the DataBind() method for every control on the page as well, whether the data is available or not.

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.