Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
What is the C# code (code behind) for adding a column to grdview in asp.net ...something equivalent to this :
<asp:BoundField DataField="Last Name" HeaderText="Last Name" SortExpression="LastName" />
BoundField boundfield = new BoundField(); boundfield.DataField = "Last Name"; boundfield.HeaderText = "Last Name"; boundfield.SortExpression= "LastName"; GridView1.Columns.Add(boundfield);
Add a comment
Something along these lines:
var column = new BoundField(); column.DataField = "LastName"; column.HeaderText = "Last Name"; column.SortExpression = "LastName"; GridView1.Columns.Add(column);
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var boundColumn = new BoundField(); boundColumn.DataField = "LastName"; boundColumn.HeaderText = "Last Name"; boundColumn.SortExpression = "LastName"; GVPictures.Columns.Add(boundColumn); BindGridView(); } }
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.