GridView templates

Posted by Carpenter under Regular Expressions on 12/12/2009 | Views : 2077 | Status : [Member] | Replies : 1
Hi... Any help on how I could format/structure/template a GridView so that the the contents from an excel spreadsheet's cells would
display as:

<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>


Here is the code I used to get a named range within the excel file into a 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)

' 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

---------------------------- the bit I'm after --------------------------------------

<!-- It doesn't do much a present but it does display the info -->
<asp:GridView ID="GridView1" runat="server" style="height: 182px"

<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" />


I don't even know if I should be using the gridview or something else - so keep it nice and simple if you can...


Posted by: RtpHarry on: 1/9/2010 [Member] [MVP] Bronze

It looks like you should use something like a repeater or listview if you want full control over the html that you emit.

The example you have given is bad html though. You need to wrap either a <ol> or <ul> tag around each block of <li> tags.

Ol is ordered list ie bullet points are 1,2,3 etc, UL is unordered list just plain bullet points.

Carpenter, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response