Question about Data Binding...

  • Thread starter Moshfegh Hamedani
  • Start date
M

Moshfegh Hamedani

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.
 
T

Thomas Dodds

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 ...

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top