Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

Datagrid - include jpegs

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jonathan - 18 Feb 2008 10:31 GMT
In one of the 4 output columns of my Datagrid, I have a Yes/No Boolean
field.

I'd like to show a graphical tick (e.g. tick.jpg) or a cross e.g.
(cross.jpg) instead of True/False or Yes/No.

How could I do that? Here's the code:

</head>

<%@ Page language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script language="VB" runat="server">

Sub Page_Load(Sender as Object, E as EventArgs)

 Dim oConn As OleDbConnection
 Dim oComm As OleDbDataAdapter
 Dim sConn As String
 Dim sComm As String
 Dim oDataSet As New DataSet

 'Build the connection string
 sConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
 sConn += "Data Source=D:\inetpub\www\mysite\myaccessdb.mdb;"
 sConn += "Persist Security Info=False"

 'Build the SQL string
 sComm = "SELECT qryDataGrid01.* "
 sComm += "FROM qryDataGrid01;"

 'Create the connection and command objects
 oConn = New OleDbConnection(sConn)
 oComm = New OleDbDataAdapter(sComm, oConn)

 'Fill the dataset with the results of the query
 oComm.Fill(oDataSet, "qryDataGrid01")

 'Set the grid source to the dataset and bind the data
 oGrid.DataSource=oDataSet.Tables("qryDataGrid01").DefaultView
 oGrid.DataBind()

End Sub
</script>

<asp:DataGrid runat="server" id="oGrid" BackColor="#eeeeee"
HorizontalAlign="Left">
<HeaderStyle Font-Bold="True"/>
<AlternatingItemStyle BackColor="White" />
</asp:datagrid>
Mark Rae [MVP] - 18 Feb 2008 11:20 GMT
> In one of the 4 output columns of my Datagrid,

DataGrid? Are you still using Visual Studio.NET 2003...?

> I'd like to show a graphical tick (e.g. tick.jpg) or a cross e.g.
> (cross.jpg) instead of True/False or Yes/No.

http://authors.aspalliance.com/aspxtreme/webforms/controls/addingtemplatecolumns
todatagrid.aspx


>  sConn += "Data Source=D:\inetpub\www\mysite\myaccessdb.mdb;"

Surely not...? The above implies that your database is in your website's
virtual root, meaning that it is fully accessible through a browser:

http://www.mysite.com/myaccessdb.mdb

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Masudur - 18 Feb 2008 11:55 GMT
> In one of the 4 output columns of my Datagrid, I have a Yes/No Boolean
> field.
[quoted text clipped - 48 lines]
> <AlternatingItemStyle BackColor="White" />
> </asp:datagrid>

Hi...

You can change your column's item template and add a image in item
template...
next in item data bound depenting on your data value change source of
the image...

please take a look at this section...
http://www.asp.net/learn/data-access/#formatting

Thanks
Md. Masudur Rahman
www.munna.shatkotha.com
www.kaz.com.bd
gnewsgroup - 18 Feb 2008 15:03 GMT
> In one of the 4 output columns of my Datagrid, I have a Yes/No Boolean
> field.
[quoted text clipped - 48 lines]
> <AlternatingItemStyle BackColor="White" />
> </asp:datagrid>

If you *can* use ASP.NET 2.0, you can use the ImageField property of
GridView.  An example is available here:

http://authors.aspalliance.com/aspxtreme/shared/viewsrc.aspx?path=/aspxtreme/sys
/web/ui/webcontrols/demos/GridViewImageField.aspx.src


Also, as Mark has pointed out, your database is located in your web
folder and can be directly downloaded, which needs to be fixed.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.