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.
 

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

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,828
Latest member
LauraCastr

Latest Threads

Top