How to add a object in DataGrid RRS feed

  • Question

  • User-1053303763 posted

    I'm have a probleme with using C#, and i need halp form everyone


    when i use a DataGrid, i coud binding the data from dataSet, but i want add some object as Panel or Button or combobox or Label in dataGrid. I have try to seache in MSDN i see that we have collumStyl only CcheckboxCollumStyl so i cannot add a button or combobox in the cell of datagrid. How coud creat the Panel or button or another object in a celle


    Friday, September 1, 2006 4:13 AM

All replies

  • User1107770998 posted

    Just add a template column, you can add any control in the template column. Contact me if you have any further questions



    Friday, September 1, 2006 10:28 AM
  • User-1053303763 posted

    Could you give me a example of this



    Sunday, September 3, 2006 11:26 PM
  • User1107770998 posted
    Following is the example from MSDN
    <%@ Page language="C#" %>

        <form runat="server">
          <h3>TemplateField Example</h3>

          <!-- Populate the Columns collection declaratively. -->
          <!-- Create a custom TemplateField column that uses      -->
          <!-- two Label controls to display an author's first and -->
          <!-- last name in the same column.                       -->
          <asp:gridview id="AuthorsGridView"
              <asp:templatefield headertext="Author Name">
                  <asp:label id="FirstNameLabel"
                    Text= '<%# Eval("au_fname") %>'
                  <asp:label id="LastNameLabel"
                    Text= '<%# Eval("au_lname") %>'
          <!-- This example uses Microsoft SQL Server and connects -->
          <!-- to the Pubs sample database.                        -->
          <asp:sqldatasource id="AuthorsSqlDataSource" 
            selectcommand="SELECT [au_lname], [au_fname], [address], [city], [state], [zip], [contract] FROM [authors]"
            connectionstring="server=localhost;database=pubs;integrated security=SSPI"
    Monday, September 4, 2006 6:58 AM