Set the value of a DataField in code behind

How you set the value of of a DataField within code behind.

Please let other users know how useful this tip is by rating it below. Do you have a tip or code of your own you'd like to share? Submit it here.


Within code behind, how do you set the value of of a DataField? This example sets the columns set by the constants COL_1 & COL_2 to refer to data columns COLUMN_1 & COLUMN_2.


    Dim xCol As BoundColumn
    xCol = CType(grdData.Columns(COL_1),
System.Web.UI.WebControls.BoundColumn)
    xCol .DataField = "COLUMN_1"
    xCol = CType(grdData.Columns(COL_2),
System.Web.UI.WebControls.BoundColumn)
    xCol .DataField = "COLUMN_2"

This was last published in February 2004

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close