|
Help! I am a beginner in ASP.NET.
I have this code below to display images from my SQL Database to my ASP.NET website. But still wont work. What did I miss? Can someone please help me sort this?
Your help is greatly appreciated. Thanks.
==========================
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" RepeatColumns="4" RepeatDirection="Horizontal" DataKeyField="imgData">
<ItemTemplate>
<asp:Label ID="EmployeeNameLabel" runat="server" Text='<%# Eval("EmployeeName") %>'>
</asp:Label><br />
Department:
<asp:Label ID="DepartmentLabel" runat="server" Text='<%# Eval("Department") %>'>
</asp:Label><br />
<asp:Image ID="Image1" runat=server ImageUrl='<%# Eval("imgData", "{0}") %>'/>
</ItemTemplate>
</asp:DataList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MYSQL%>"
SelectCommand="SELECT [EmployeeID], [EmployeeName], [Department], [imgData] FROM [tblStaff]">
</asp:SqlDataSource>
aigreen.net
|
|
|
|
|
imgdata is of image type?
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
Yes, it is an image type. I am getting problem in my code expression in binding to image url just to display my image using datalist.
aigreen.net
|
|
|
|
|
whar code u r using ? can i see it?
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
Below is the whole code: in ASP.NET
=======================
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Display.aspx.vb" Inherits="Display" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" RepeatColumns="4" RepeatDirection="Horizontal" DataKeyField="imgData">
<ItemTemplate>
<asp:Label ID="EmployeeNameLabel" runat="server" Text='<%# Eval("EmployeeName") %>'>
</asp:Label><br />
Department:
<asp:Label ID="DepartmentLabel" runat="server" Text='<%# Eval("Department") %>'>
</asp:Label><br />
Position:
<asp:Label ID="PositionLabel" runat="server" Text='<%# Eval("Position") %>'></asp:Label><br />
email:
<asp:Label ID="emailLabel" runat="server" Text='<%# Eval("email") %>'></asp:Label><br />
<asp:Image ID="Image1"
runat=server
ImageUrl=
'<%# Eval("imgData", "{0}") %>'
/>
<br />
<br />
</ItemTemplate>
</asp:DataList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MYSQL %>"
SelectCommand="SELECT [EmployeeID], [EmployeeName], [Department], [Position], [email], [rank], [imgData] FROM [tblStaff]">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
aigreen.net
|
|
|
|
|
if u have a image datatype , then for retrieving the pic u
http://aspalliance.com/140_Retrieving_Images_from_SqlServer_in_ASP_NET[^]
Hope this will help u.
Please let me know if u still face the problem.
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
How can i make the dsn for sql server 2000 programatically?
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
How should i make a crystal report formula field for the date
In the database it is 12/12/2000 23:10:12
i want 12/12/2000
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
Hello,
I have datatable and it is populated with some values.
Is it possible to add a column in an exiting datatable now with a auto increment values?
I am trying like this but it does'nt wotk
dslistItems1.Tables[0].Columns.Add("ID", Type.GetType("System.Int32"));
DataColumn[] pk = new DataColumn[1];
pk[0] = dslistItems1.Tables[0].Columns["ID"];
//dslistItems1.Tables[0].PrimaryKey = pk;
dslistItems1.Tables[0].Columns["ID"].AutoIncrement = true;
dslistItems1.Tables[0].Columns["ID"].AutoIncrementSeed = 1;
dslistItems1.Tables[0].Columns["ID"].ReadOnly = true;
This code doesn't populate the values in the column
Regards,
Pavas
|
|
|
|
|
You are trying to use this code to create a new column in the database? The DataSet is a disconnected, in-memory representation of the database, if you want to add a column into the actual database table you'll need to issue an ALTER table sql statement.
only two letters away from being an asset
|
|
|
|
|
No I do not want to add it to database table. I have a populated datatable and then I want to add an autoincrement datacolumn to a data table.
The purpose is I want to create relations among other datatables present in the dataset.
Regards,
Pavas
|
|
|
|
|
|
please can any one help me to solve my error when i run the setup of my vb.net application then an error occur like
"the type initializer for CrystalDecisions.CrystalReports.Engine.ReportDocument threw an exception"
its urgent
|
|
|
|
|
hi ravi
i am new but working on VS 2005. After reading your post i just understand that your application consist of Crystal Report but at the time of installation it throws installation. I searched on the google got the following link. Hope this will help you.
Thanks & Regards
Dilip
.Net Consulting
|
|
|
|
|
Hi all ,
I am using Asp.Net 1.1.. How can Enumurate all the rows in a datagrid ? .This works in 2.0. But what about 1.1
For each Row as GridViewRow in GridView1.Rows
Next Row
Thanks in advance
Dana
modified on Thursday, January 17, 2008 7:20:50 AM
|
|
|
|
|
There's a clue in the variable types here, if you look for it... Or you could look at what type of row a collection of rows in a datagrid contains.
|
|
|
|
|
dear all,
i have developed a web application using asp.Net 2.0, i have a database,site on X machine (works as domain). i have access that site from client Y machine.
Application copy the file from Z machine to X machine, Z machine under the domain (X machine). i have copy file with following code
my.computer.network.download("http://IP of Z machine/folder/fileName","Location on X machine")
when i execute the code it will throughs an execption of "UnAuthorisation" on above code.
i have login on Z machine from X machine (with IP and Computer name also)
where i am wrong???
what should i do?
please help...
thankx in advance
koolprasad2003
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
can any one help me to create a vb.net application in which i have a list view control with print command
thanks in advance
|
|
|
|
|
how to create administrator username,password and user username,password in only one login control?
|
|
|
|
|
Basheer wrote: how to create administrator username,password and user username,password in only one login control?
You might want to rephrase that because it doesn't make much sense.
|
|
|
|
|
i am developing an website for online billing of computer parts.
here i want to allow users to select a part number , then the price and part number should come automatically. This i need to get in a grid format.
eg:
partno name quantity price total
1001 part1 1 100.00 100.00
Initailly i just want to show one row only.. and in that need to show the combo box only..
The partno is taken from parts table and this will be inserted to invoiceitem tables
Can i use datagrid for this? Please help me for a solution
regards
Hari
|
|
|
|
|
Yes you can use datagrid for this purpose (displaying set of records from the database).
Apurva Kaushal
|
|
|
|
|
Hello,
I have created a placeholder to will contain labels and textboxes based on the users choice from a dropdown. I would like to place every label and textbox in a seperate td in a table. How can I create a td for every label and textbox? Thanks.
Here is part of the code:
<asp:DropDownList ID="NumOfQuestionsDropDown" runat="server" AutoPostBack="True" OnSelectedIndexChanged="NumOfQuestionsDropDown_SelectedIndexChanged" >
</asp:DropDownList>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
void CreateLabelsTextBoxes()
{
int n = Int32.Parse(NumOfQuestionsDropDown.SelectedItem.Value);
// create n Labels and TextBoxes, and add them to the PlaceHolder TextBoxesHere
for (int i = 0; i < n; i++)
{
PlaceHolder1.Controls.Add(new Label());
PlaceHolder1.Controls.Add(new TextBox());
}
// Set the Text property of each Label
IterateThroughChildren(this);
}
void IterateThroughChildren(Control parent)
{
int count = 1;
foreach (Control c in parent.Controls)
{
if (c.GetType().ToString().Equals("System.Web.UI.WebControls.Label") && c.ID == null)
{
((Label)c).Text = "Question" + count;
count++;
}
Response.Write("Type= " + c.GetType() + "<br />");
if (c.Controls.Count > 0)
{
IterateThroughChildren(c);
}
}
}
protected void NumOfQuestionsDropDown_SelectedIndexChanged(object sender, EventArgs e)
{
CreateLabelsTextBoxes();
}
|
|
|
|
|
My database is sql server 2000 ,I have a name and date colums in a table . How should I write the query to find all the names which lies in the particular year , In order to access it from --- the asp.net c# code behind file?
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
The raw SQL would be something like this:
SELECT MyName FROM MyTable WHERE DATEPART(year, MyDate) = @MyYear
That should be wrapped up into a stored procedure
CREATE PROCEDURE GetNames
@Year int
AS
SELECT MyName FROM MyTable WHERE DATEPART(year, MyDate) = @Year
GO
You can then write the C# code (from anywhere, as it is ADO.NET that connects to the database - It has nothing to do with ASP.NET)
using(SqlConnection conn = new SqlConnection(myConnectionString))
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "GetNames";
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
string name = reader.GetString(0);
}
}
|
|
|
|