Retrival of image in Gridview
How to retrieve image from database in a grid view and alwas in outpot the size of image shown equal while we store image in database with diffrent size.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Sep 19, 2012, 7:33 PM EDT
Try this...
Default.aspx code
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
Default.aspx.vb code
Imports System.Data.SqlClient
Imports System.Data
Partial Class _Default
Inherits System.Web.UI.Page
Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
Dim con As New SqlConnection(strConnString)
Dim com As SqlCommand
Dim sqlda As SqlDataAdapter
Dim ds As DataSet
Dim str As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
bindgrid()
End Sub
Sub bindgrid()
con.Open()
str = "SELECT * FROM student"
com = New SqlCommand(str, con)
sqlda = New SqlDataAdapter(com)
ds = New DataSet()
sqlda.Fill(ds, "student")
GridView1.DataSource = ds
GridView1.DataMember = "student"
GridView1.DataBind()
con.Close()
End Sub
Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging
GridView1.PageIndex = e.NewPageIndex
bindgrid()
End Sub
End Class
Thanks
If this post helps you mark it as answer
Satyapriya NayakRank #47 · 31.5K reputationPosted Sep 19, 2012, 7:39 PM EDT
Swati AgarwalRank #1,589 · 999 reputationPosted Sep 19, 2012, 7:57 PM EDT