2009-12-12 2 views
2

내가/구조/A의 GridView를 템플릿 형식을 수있는 방법에 대한 도움이되도록 엑셀 스프레드 시트의 셀의 내용처럼 디스플레이 : 여기 의 GridView 템플릿

<li>"looking to display data from column1 here between the li tags"</li> 
    <p>"and data from column2 here between the p tags"</p> 

<!-- and so row two from excel/objDataset1 would do the same --> 
    <li>"data from column1 here"</li> 
    <p>"data from column2 here"</p> 

etc... 

가 나는 이름을 얻기 위해 사용되는 코드입니다 엑셀에서 범위가있는 gridview에 파일 :

Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _ 
       & "Data Source=" & Server.MapPath("Spreadsheet.xls") _ 
       & ";" & "Extended Properties=Excel 8.0;" 
    ' original code was: & "Data Source=" & Server.MapPath("../ExcelData.xls") _ ' ??? 


    Dim objConn As New OleDbConnection(sConnectionString) 
    objConn.Open() 

    ' Create new OleDbCommand to return the data from the worksheet/RangeName. 
    Dim objCmdSelect As New OleDbCommand("SELECT * FROM RangeName", objConn) 
    Dim objAdapter1 As New OleDbDataAdapter() 
    objAdapter1.SelectCommand = objCmdSelect 
    Dim objDataset1 As New DataSet() 

    ' Fill the DataSet with the information from the worksheet/RangeName. 
    objAdapter1.Fill(objDataset1, "XLData") ' ?!?!? 

    ' Build 
    GridView1.DataSource = objDataset1.Tables(0).DefaultView 
    GridView1.DataBind() 
    objConn.Close() 

---------------------------- 난 후 비트 --------------------------------------

<!-- It doesn't do much a present but it does display the info --> 
<asp:GridView ID="GridView1" runat="server" style="height: 182px" 
    BackColor="Transparent" 
    BorderColor="#DEDFDE" 
    BorderStyle="None" 
    BorderWidth="1px" 
    CellPadding="4" 
    ForeColor="Black" 
    GridLines="None"> 


    <RowStyle BackColor="Transparent" 

    /> 

    <FooterStyle BackColor="#CCCC99" /> 

    <%-- <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" /> 
    <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" /> 
    <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />--%> 
    <%-- I do not want to show the column header info from the excel file - which is coming through - also --%> 


    <AlternatingRowStyle BackColor="Transparent" /> 

</asp:GridView> 

나는 심지어 내가있는 gridview 또는 뭔가를 사용해야하는지 모른다 - 당신은 스프레드 시트보고하고자하는 경우에 너무 좋은 당신이 할 수있는 경우에 간단하게 ...

+0

무엇 당신이 그것을 할 싶지 않아 지금하고 있습니까? 아니면 뭘 더 원합니까? – Rap

답변

1

있는 gridview는 좋은 선택이다 웹 페이지의 데이터. 바로 그것이 설계된 것입니다.

그런데 <li> s를 <p>과 혼합하면 나쁜 형태입니다. <p></p><li></li> 내에 완전히 존재할 수 있지만 <li> 요소는 다른 모든 요소를 ​​완전히 둘러 쌀 것을 의미합니다. 다른 말로하면 <ul>에 직계 하위 태그를 추가해서는 안됩니다.

편집 : 예, 카펜터, 가깝습니다. <li> s 내에 서식을 지정하는 데 문제가 없습니다. Divs를 사용하여 <li> 안에 전체 서식을 넣으면됩니다. 예 :

<html> 
<head> 
<style type="text/css"> 
.Question { 
    background-color: orange; 
} 
.Answer { 
    font-weight: bold; 
} 
</style> 
</head> 
<body> 
<ol> 
<li> 
    <div> 
    <p class="Question">Q: Why is SO so awesome?</p> 
    <p class="Answer">A: Because the community writes the questions.</p> 
    </div> 
</li> 
<li> 
    <div> 
    <p class="Question">Q: Should I join?</p> 
    <p class="Answer">A: Yes, if you want to help the community by upvoting good questions and answers.</p> 
    </div> 
</li> 
<li> 
    <div> 
    <p class="Question">Q: Do you have to join?</p> 
    <p class="Answer">A: No, you can ask questions and read answers anonymously.</p> 
    </div> 
</li> 
</ol> 
</body> 
</html> 

그 대답 섹션을 사용에 대해 걱정하지 마십시오 ... 당신이/편집 언급을 충분히 명성을 가지고 있지 않지만, 당신은 내가 당신의 질문을 upvoting하여 준 10 이후에 더 가까운 것 . :-)

0

답변 섹션을 작성하는 것에 대해 유감스럽게 생각합니다. 랩 - Openid가 없으므로 여기에서 사용하는 해결 방법입니다. 도와 주셔서 고마워요 ...

나는 둘 다 질문과 그에 대한 답변이있는 것처럼, 그리고 li의 모양을 보았습니다. 그 때 ap 태그가 나에게 꽤 멋져 보였습니다. - 레이아웃 현명한 ... 그것은 리 텍스트가되어야합니까
텍스트 다음 다른 리 ... 괜찮습니까?

0

끝 부분에서 어떻게 작동하는지 보여 주기만하면 ... & 코드에 대한 팁이 있습니까?

' Create connection string variable. Modify the "Data Source" parameter as 
    ' appropriate for your environment. 
    Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _ 
       & "Data Source=" & Server.MapPath("Spreadsheet.xls") _ 
       & ";" & "Extended Properties=Excel 8.0;" 
    ' original: & "Data Source=" & Server.MapPath("../ExcelData.xls") _ 


    Dim objConn As New OleDbConnection(sConnectionString) 
    objConn.Open() 
    ' Create new OleDbCommand to return data from worksheet/RangeName. 
    Dim objCmdSelect As New OleDbCommand("SELECT * FROM RangeName", objConn) 
    Dim objAdapter1 As New OleDbDataAdapter() 
    objAdapter1.SelectCommand = objCmdSelect 

    ' Create new DataSet to hold information from the worksheet/RangeName. 
    Dim objDataset1 As New DataSet() 

    ' Fill the DataSet with the information from the worksheet/RangeName. 
    objAdapter1.Fill(objDataset1, "XLData") 

    ' Create a new DataTable object 
    Dim MyTable = New DataTable 
    MyTable = objDataset1.Tables(0) 

    ' Find how many rows are in the Rows collection 
    ' of the new DataTable object. 
    Dim numrows = MyTable.Rows.Count 

    If numrows = 0 Then 
     display_htmlstring.InnerHtml = "<p>No records found.</p>" 
    Else 

     Dim rowashtml As String 
     rowashtml = "<ol>" 

     For loop1 = 0 To numrows - 1 
' the excel rangename has column headings of Problem & Answers 
      rowashtml = rowashtml & "<li>" & Server.HtmlEncode(MyTable.Rows(loop1).Item("Problem")) _ 
       & "<p>" & Server.HtmlEncode(MyTable.Rows(loop1).Item("Answers")) & "</p></li>" 

     Next loop1 
     display_htmlstring.InnerHtml = rowashtml & "</ol>" 
    End If 

------------------------ the girdView is gone and I am now using just --------------- 

<div id="display_htmlstring" runat="server"> 
    </div> 

덕분에 다시 도움을 RAP (리 P "여기 너무"P 리 "물건 hopefuly 여기에있을 수 있습니다")