views:

605

answers:

3

Hello

using Bind in a GridView control template enables the control to extract values from child controls in the template and pass them to the data source control. The data source control in turn performs the appropriate command for the database. For this reason, the Bind function is used inside the EditItemTemplate or InsertItemTemplate of a data-bound control.


Why is Bind() needed to extract values and pass them to GridView. Why isn’t GridView able to extract child control’s values directly?


thanx

A: 

how can you extract values if they are yet not assigned ? you have to use Bind as mentioned so the values are retrieved from DB, then you use ItemDataBound event and findcontrol then extract it's value.

hope this helps.

A: 

What it says there is only this

myGridView.DataSource = new string { "1", "2", "3", "4", "5" };

will never work, but this:

myGridView.DataSource = new string { "1", "2", "3", "4", "5" };
myGridView.DataBind();

will

balexandre
A: 

the first one wont work because setting the datasource property is only telling the gridview that this will be the source of the data. the 2nd one sets the datasource property AND specifically instructs the gridview to bind to that source and fetch the data...

frap