C# .NET - griedview

Asked By indramani tiwary
09-Feb-12 02:00 AM
how to display image in griedview
  Lalit M. replied to indramani tiwary
09-Feb-12 02:03 AM
Hi..

show this link for display image in grid view in different way you.. get source code

http://www.shabdar.org/asp-net/81-display-images-in-gridview-from-database-in-aspnet.html 
  dipa ahuja replied to indramani tiwary
09-Feb-12 02:56 AM
Step 1: Add a handle in your website and write this code in ProcessRequest:
public void ProcessRequest (HttpContext context)
{
  SqlConnection con = new SqlConnection();
  con.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
 
  // Create SQL Command
 
  SqlCommand cmd = new SqlCommand();
  cmd.CommandText = "Select pname,images from Photos where id =@id";
  cmd.CommandType = System.Data.CommandType.Text;
  cmd.Connection = con;
 
  SqlParameter ImageID = new SqlParameter("@id", System.Data.SqlDbType.Int);
  ImageID.Value = context.Request.QueryString["id"];
  cmd.Parameters.Add(ImageID);
  con.Open();
  SqlDataReader dReader = cmd.ExecuteReader();
  dReader.Read();
  context.Response.BinaryWrite((byte[])dReader["images"]);
  dReader.Close();
  con.Close();
}
 
Step 2: Add a Image Control in ItemTemplate:
 
<ItemTemplate>
  <asp:Image ID="Image1" runat="server"
ImageUrl='<%# "Handler.ashx?id=" + Eval("id")%>'/>
</ItemTemplate>
 
//display image from the database using handler
Image2.ImageUrl = "Handler.ashx?id=2";
 
 
 
 
Create New Account
help
Framework i have this function which call an sp that has a return code public SqlDataReader fn_SpecData(Int32 iDate, Int32 iRange, out Int32 iRowCount) { string constr = ConfigurationManager.ConnectionStrings["arlcapConnectionString"].ConnectionString; SqlConnection sqlcon1 = new SqlConnection(constr); SqlCommand sqlcmd1 = sqlcon1.CreateCommand(); sqlcmd1.CommandType = CommandType.StoredProcedure; sqlcmd1.CommandText = "sp_getRatingSummaryRange"; sqlcmd1.Parameters.AddWithValue iDate", iDate); sqlcmd1.Parameters.AddWithValue("@iRange", iRange); SqlParameter RowCount = sqlcmd1.Parameters.Add("@isOK", null); RowCount.SqlDbType = SqlDbType.Int; RowCount.Direction = ParameterDirection.ReturnValue; sqlcon1.Open(); iRowCount = Convert.ToInt32(RowCount.Value); return sqlcmd1.ExecuteReader invalid or 1 valid for a userid and password string constr = ConfigurationManager.ConnectionStrings["arlcapConnectionString"].ConnectionString; SqlConnection sqlcon1 = new SqlConnection(constr); SqlCommand sqlcmd1 = sqlcon1.CreateCommand(); sqlcmd1.CommandType = CommandType.StoredProcedure; sqlcmd1.CommandText = "sp_getSectorCount"; SqlParameter rowcount = sqlcmd1.Parameters.Add("@rowcount", null); rowcount.SqlDbType = SqlDbType.Int; rowcount.Direction = ParameterDirection.ReturnValue; sqlcon1.Open(); sqlcmd1.ExecuteNonQuery(); sqlcon1.Close(); sqlcmd1.Dispose(); sqlcon1
This is the code for the class form that I am using: - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- public class SqlserverData { SqlConnection sqlconnection = new SqlConnection("data source = .;initial catalog = ECASH;integrated security = true"); public bool LoadNumtel(ref DataTable dtblMylogin, ref typeof(string)); DataRow drTransationM; dtblozekimessageout.Columns.Add("receiver", typeof(string)); DataRow drOzekimessageout; bool bsuccess = true; / / SqlConnection con = new SqlConnection(sqlconnection); try { SqlCommand cmd = new SqlCommand("clientReport", sqlconnection); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add("@numtel", System.Data.SqlDbType.VarChar); cmd.Parameters["@numtel"].Value = sNumtelSearch; sqlconnection.Open(); SqlDataReader dtr = cmd.ExecuteReader(); if (dtr.HasRows
publisher like %@Keyword% or" + "location like %@Keyword%"); SqlParameter param = new SqlParameter(); param.ParameterName = "@Keyword"; param.SqlDbType = SqlDbType.VarChar; param.Value = keyword; comm.Parameters.Add(param); comm.Connection = conn; and i got the publisher like '%@Keyword%' or" + "location like '%@Keyword%'"); SqlParameter param = new SqlParameter(); param.ParameterName = "@Keyword"; param.SqlDbType = SqlDbType.VarChar; param.Value = keyword; comm.Parameters.Add(param); comm.Connection = conn; the values should be enclosed in single quotes. regards, gopinath g. still get the same error. . . SqlConnection conn = new SqlConnection("server = localhost;initial catalog" +" = library;integrated security = yes"); conn.Open(); try { SqlCommand comm = new SqlCommand publisher like '%@Keyword%' or" + "location like '%@Keyword%'"); SqlParameter param = new SqlParameter(); param.ParameterName = "@Keyword"; param.SqlDbType = SqlDbType.VarChar; param.Value = keyword; comm.Parameters.Add(param); comm.Connection = conn; ArrayList bkList = new ArrayList
SqlDataReader is not fetching in the table Hi!can someone help, I have a problem with my SqlDataReader it is not fetching any records from the database. here is my code using a Add("nom", typeof(string)); dtbMylogin.Columns.Add("prenom", typeof(string)); DataRow drMylogin; bool bsuccess = true; SqlConnection sqlconnection = new SqlConnection(sconStr); try { SqlCommand sqlcomm = new SqlCommand("ReportForAllClient", sqlconnection); sqlcomm.CommandType = System.Data.CommandType.StoredProcedure; sqlcomm.Parameters.Add("@numtelClient", System.Data.SqlDbType.BigInt); sqlcomm.Parameters["@numtelClient"].Value = sNumtelSearch sqlconnection.Open(); SqlDataReader dtr = sqlcomm.ExecuteReader(); if (dtr.HasRows) { / / First Dataset for main report while (dtr
this snippet in Page_Load. string strSQLconnection = "Data Source = dbServer;Initial Catalog = testDB;Integrated Security = True"; SqlConnection sqlConnection = new SqlConnection(strSQLconnection); SqlCommand sqlCommand = new SqlCommand("GetDetails", sqlConnection); sqlCommand.CommandType = CommandType.StoredProcedure; sqlConnection.Open(); SqlDataReader reader = sqlCommand.ExecuteReader(); GridView1.DataSource = reader; GridView1.DataBind(); Check this link for more info - http object sender, EventArgs e) { string strSQLconnection = "Data Source = dbServer;Initial Catalog = testDB;Integrated Security = True"; SqlConnection sqlConnection = new SqlConnection(strSQLconnection); SqlCommand sqlCommand = new SqlCommand( "SPName", sqlConnection); sqlCommand.CommandType = CommandType.StoredProcedure; sqlConnection.Open