Click here to Skip to main content
15,914,447 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
http://i.stack.imgur.com/6bM6O.png[^]

Please check the image above and please help me solve my issue. If you guys need code i can definitely provide by editing my question that i have asked here.


Code Below of Html
ASP.NET
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="InputPage.aspx.vb" Inherits="GBATExcel.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
        <style>
            .fixedColWidth td
            {
             width: 150px;
            }
        </style>
        <asp:Panel runat="server" Width="3000"/>
        <asp:Table ID="tblLists" runat="server" CssClass="fixedColWidth" CellPadding="0" CellSpacing="0">
        <asp:TableRow ID="trLists" runat="server"></asp:TableRow>
        </asp:Table>
        
        &nbsp;<asp:GridView ID="GridView1" runat="server" CssClass="fixedColWidth" CellPadding="0" CellSpacing="0" ForeColor="#333333" Height="273px">
              <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
              <EditRowStyle BackColor="#999999" />
              <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
              <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
              <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
              <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
              <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
              <SortedAscendingCellStyle BackColor="#E9E7E2" />
              <SortedAscendingHeaderStyle BackColor="#506C8C" />
              <SortedDescendingCellStyle BackColor="#FFFDF8" />
              <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
              </asp:GridView>
 &nbsp;&nbsp;<br />
        &nbsp;
        <div>
            <asp:Button ID="InputPageSubmitButton" runat="server" Text="Submit" Width="149px" />
        </div>
    </form>
</body>
</html>



Code below of asp.net vb code
VB.NET
Public Class WebForm1
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Load Excel File on Page Load 
        loadExcel()
End Sub


VB.NET
Private Sub Page_PreRender(sender As Object, e As System.EventArgs) Handles Me.PreRender
    trLists.Cells.Clear()
    For i As Integer = 0 To GridView1.Rows(0).Cells.Count - 1
        Dim dd1 As New DropDownList()
        dd1.ID = "dd1" + i.ToString()
        dd1.Width = Unit.Pixel(105.2)
        dd1.Items.Add("Borough")
        dd1.Items.Add("Borough")
        dd1.Items.Add("Borough")
        dd1.Items.Add("Borough")
        dd1.Items.Add("Borough")
        dd1.Items.Add("Borough")
        Dim cell As New TableCell()
        cell.Controls.Add(dd1)
        trLists.Cells.Add(cell)
    Next
End Sub

VB.NET
Public Function loadExcel() 'loadExcel Function to show the file to the gridView.
Dim MyConnection As System.Data.OleDb.OleDbConnection
        Dim DtSet As System.Data.DataSet
        Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
        'Dim filePath = Path.Combine(GlobalVariable.savedPath, GlobalVariable.excelFileName)
        Dim filePath = "C:\excelfiles\Book11.xlsx"
        'Code to Use an Oledb Connection to get data from the Excel File
        MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & filePath & ";Extended Properties='Excel 12.0 Xml;HDR=YES;';")
        'Code to Read the Sheet Selected from the Excel Spread Sheet'
        MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection)
        '-- Extra Code Not Needed which Maps the tables as Columns from the Spreadsheet
        'MyCommand.TableMappings.Add("Table", "Net-informations.com")
        DtSet = New System.Data.DataSet
        MyCommand.Fill(DtSet)
        'Populates GridView with the excel Spreadsheet
        GridView1.DataSource = DtSet.Tables(0)
        'Code Below needed to show the excel to GridView
        GridView1.DataBind()
        MyConnection.Close()

        Return Nothing
    End Function
    Protected Sub InputPageSubmitButton_Click(sender As Object, e As EventArgs) Handles InputPageSubmitButton.Click
        Response.Redirect("OutputSelectPage.aspx", True)
    End Sub

    Protected Sub GridView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridView1.SelectedIndexChanged

    End Sub
End Class


What I have tried:

StackOverflow. I basically tried researching a lot on my own but need help because this is necessary to be done soon .
Posted
Updated 26-Apr-16 8:57am
v4
Comments
Suvendu Shekhar Giri 26-Apr-16 15:51pm    
One idea can be to have a grid view instead of table which will have the same width as the second gridview.
JT1992 26-Apr-16 15:58pm    
Can you provide a code example from my code please?
JT1992 26-Apr-16 16:48pm    
Isn't a grid view rendered as a table how would that make any difference?
Suvendu Shekhar Giri 27-Apr-16 2:38am    
Not exactly. You can see some span as well and that can change the design.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900