asp.net.ph

BaseDataList.DataBind Method

System.Web.UI.WebControls Namespace   BaseDataList Class


Binds a data source to the control.

[ VB ]
Overrides Public Sub DataBind ( )

[ C# ]
public override void DataBind ( );

[ C++ ]
public: void DataBind ( );

[ JScript ]
public override function DataBind ( );

Remarks

Use the DataBind method to bind the data source specified by the DataSource property with the data list control. By binding the data source with a data listing control, the information in the data source is displayed in a data listing control.

The DataBind method is also commonly used to synchronize the data source and a data listing control after information in the data source is updated. This allows any changes in the data source to also be updated in a data listing control.

Example

The below snippet demonstrates how to dynamically bind a data source to a DataList control when the page loads at run time. The data source in this case is an SqlDataReader.

<script language = "C#" runat = "server">
   void Page_Load ( Object src, EventArgs e ) {
      // ... code to fetch data into a datareader here ...

      // bind the datalist to the datareader
      myList.DataSource = myReader;
      myList.DataBind ( );

      // close the connection
      myConn.Close ( );
   }
</script>

<asp:datalist id = "myList" repeatcolumns=2 runat = "server">
   ...
</asp:datalist>
  C# VB

 Show me 

See Also

BaseDataList Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph