i have sql table like
sno name fathername imagepath house.no colony
1 raju vamshi raju.jpg 5-6 chaithanya nagar
2
3
4
5
i want o/p like ....
i want display person details in group and with image in gridview or ............
plz write the code............
Loading
Munesh SharmaPosted Mar 24, 2014, 1:05 AM
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns = "false"
Font-Names = "Arial" Caption = "Using ImageControl" >
<Columns>
<asp:BoundField DataField = "ID" HeaderText = "ID" />
<asp:BoundField DataField = "name" HeaderText = "Name" />
<asp:BoundField DataField = "FatherName" HeaderText = "FatherName" />
<asp:BoundField DataField = "image" HeaderText = "Image Name" />
<asp:TemplateField>
<ItemTemplate>
<asp:Image ID="Image1" Height = "100" Width = "100" runat="server"
ImageUrl = '' />
ItemTemplate>
asp:TemplateField>
Columns>
asp:GridView>
ON Page Load_event..
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
String strConnString = System.Configuration.ConfigurationManager.
ConnectionStrings["conString"].ConnectionString;
string strQuery = "select ID, Name,iamgename,fathername from tblFiles order by ID";
SqlCommand cmd = new SqlCommand(strQuery);
SqlConnection con = new SqlConnection(strConnString);
SqlDataAdapter sda = new SqlDataAdapter();
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
try
{
con.Open();
sda.SelectCommand = cmd;
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
GridView2.DataSource = dt;
GridView2.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
con.Close();
sda.Dispose();
con.Dispose();
dt.Dispose();
}
}
Abhay ShankerPosted Mar 24, 2014, 5:12 AM
http://www.codeproject.com/Articles/20782/Displaying-Images-from-a-Database-in-a-GridView
Manoranjan GuptaPosted Mar 24, 2014, 1:01 AM