希望下拉列表框与其对应的每个网格视图列的大小相同. [英] Want the drop down list boxes to be the same size as each grid view column it corresponds to.
问题描述
http://i.stack.imgur.com/6bM6O.png [
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
<%@ 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>
<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>
<br />
<div>
<asp:Button ID="InputPageSubmitButton" runat="server" Text="Submit" Width="149px" />
</div>
</form>
</body>
</html>
asp.net vb代码下面的代码
Code below of asp.net vb code
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
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
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 .
推荐答案
",MyConnection) ' -不需要额外的代码,该代码将表格映射为电子表格中的列 ' MyCommand.TableMappings.Add("Table","Net-informations.com") DtSet = 新建 System.Data.DataSet MyCommand.Fill(DtSet) ' 使用excel电子表格填充GridView GridView1.DataSource = DtSet.Tables( 0 ) ' 下面的代码需要向GridView显示excel GridView1.DataBind() MyConnection.Close() 返回 什么都没有 结束 功能 受保护的 子 InputPageSubmitButton_Click(发送方 As 对象,例如 As EventArgs)句柄 InputPageSubmitButton.点击 Response.Redirect(" ,> True ) 结束 子 受保护的 子 GridView1_SelectedIndexChanged(发送方 As 对象,例如 As EventArgs)句柄 GridView1.SelectedIndexChanged 结束 子 结束 类
", 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 .
这篇关于希望下拉列表框与其对应的每个网格视图列的大小相同.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!