The Bind method, however, has been specifically designed for those controls that also support the update or insert data, as it allows for what has been called the "two way databinding" technique that is to bridge between the presentation of data and the writing in the data source. The method should be used in fact, within the template as EditItemTemplate or InsertItemTemplate, its controls such as GridView, FormView or the DetailsView.
Code:
<Asp: GridView ID = "grid" runat = "server" DataSourceID = "ObjectDataSource1" AutoGenerateColumns = "False">
<Columns>
<Asp: TemplateField>
<ItemTemplate>
<Asp: Image ID = "img" ImageUrl ='<%# Eval ("Img", "images / {0}")%> 'runat = "server" />
</ ItemTemplate>
<EditItemTemplate>
<Asp: TextBox ID = "txt" Text ='<%# Bind ("Img")%> 'runat = "server" />
</ EditItemTemplate>
</ Asp: TemplateField>
</ Columns>
</ Asp: GridView>
In addition, there are cases where, the Bind method must be used within the ItemTemplate template, as it may have to provide the data of such a column operation which is done server side, even if the specific column is not actually changed, as, perhaps, was marked as ReadOnly. It 's the case, these columns contain identifiers and unique keys.
Bookmarks