Note that there are some explanatory texts on larger screens.

plurals
  1. POcreating a dropdownlist in the header of the gridview while populating its column data from excel sheet
    primarykey
    data
    text
    <p>I need to create a gridview which </p> <ol> <li>fills its column with data from an excel sheet and</li> <li>for each column in the gridview ,the header should contain a drop down list with listitems like telephone,name,price which the user will select and set as the header for the particular column. </li> </ol> <p>I imported data into gridview but i am not able to create a drop down list in the gridview. If i try to create a dropdownlist in the designer page,it is just creating the dropdownlist in the gridview header but not populating the data.So How can i create a dropdownlist in the header of the gridview while populating its column data from excel sheet. Please help.</p> <p>the code i used to populate data into gridview is </p> <pre><code>Dim con As String = "" Select Case Extension Case ".xls" 'Excel 97-03 con=ConfigurationManager.ConnectionStrings("Excel03ConString").ConnectionString() Exit Select Case ".xlsx" 'Excel 07 con =ConfigurationManager.ConnectionStrings("Excel07ConString").ConnectionString() Exit Select End Select con = String.Format(con,Path) Dim connExcel As New OleDbConnection(con) Dim str As String = "SELECT * From [Sheets$]" Dim cmdExcel As New OleDbCommand(str, connExcel) Dim da As New OleDbDataAdapter(cmdExcel) Dim dset As New DataSet() da.Fill(dset, "Tabledata") Dim dtable As DataTable = ds.Tables(0) GridView1.DataSource = dset.Tables(0).DefaultView GridView1.DataBind() </code></pre> <p>and the code to create drop down list is </p> <pre><code>&lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"&gt; &lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;HeaderTemplate&gt; &lt;asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"&gt; &lt;asp:ListItem Text="name " Value="Description of Goods" /&gt; &lt;asp:ListItem Text="telephone" Value="Count" /&gt; &lt;asp:ListItem Text="price" Value="Weight" /&gt; &lt;asp:ListItem Text="Value" Value="Value" /&gt; &lt;/asp:DropDownList&gt; &lt;/HeaderTemplate&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload