show images in gridview using datalist
multiple images in grid
.aspx code
<asp:GridView ID="GridView4" runat="server" class="table" CssClass="Grid" AutoGenerateColumns="False" Width="100%">
<Columns>
<asp:TemplateField HeaderText="Mid Treatment Images">
<ItemTemplate>
<asp:DataList ID="Repeater2" runat="server" RepeatDirection="Horizontal" CellSpacing="6" CellPadding="4" RepeatColumns="4" Width="100%">
<ItemTemplate>
<div class="col-lg-3a" style="font-family : Calibri">
<img src='/initial/<%# Eval("mid1") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid2") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid3") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid4") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid5") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid6") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid7") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid8") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid9") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid10") %>' style="width: 80px; height: 80px;">
</div>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
aspx.cs
protected void showmidtreatment()
{
string cs = ConfigurationManager.AppSettings["doctor_DB"];
cn = new SqlConnection(cs);
cn.Open();
string k = "select * from painvestigation where pid='" + Label1.Text + "'";// and status='" + status + "'";
cm = new SqlCommand(k, cn);
dr = cm.ExecuteReader();
GridView4.DataSource = dr;
GridView4.DataBind();
dr.Close();
foreach (GridViewRow gv1 in GridView4.Rows)
{
DataList repeater = (DataList)gv1.Cells[0].FindControl("Repeater2");
string k1 = "select * from painvestigation where pid='" + Label1.Text + "'";
cm = new SqlCommand(k1, cn);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cm);
da.Fill(ds);
repeater.DataSource = ds;
repeater.DataBind();
}
}
single images in grid
aspx code
<asp:GridView ID="GridView6" runat="server" class="table" CssClass="Grid" AutoGenerateColumns="False" Width="100%">
<Columns>
<asp:TemplateField HeaderText="Upload Upper and Lower Impressions Photos">
<ItemTemplate>
<asp:DataList ID="Repeater4" runat="server" RepeatDirection="Horizontal" CellSpacing="6" CellPadding="4" RepeatColumns="4" Width="100%">
<ItemTemplate>
<div class="col-lg-3a" style="font-family : Calibri">
<img src='/initial/<%# Eval("upperlower") %>' style="width: 80px; height: 80px;">
</div>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
.aspx.cs code
protected void showupperlower()
{
string cs = ConfigurationManager.AppSettings["doctor_DB"];
cn = new SqlConnection(cs);
cn.Open();
string k = "select * from painvestigation where pid='" + Label1.Text + "'";// and status='" + status + "'";
cm = new SqlCommand(k, cn);
dr = cm.ExecuteReader();
GridView6.DataSource = dr;
GridView6.DataBind();
dr.Close();
foreach (GridViewRow gv1 in GridView6.Rows)
{
DataList repeater = (DataList)gv1.Cells[0].FindControl("Repeater4");
string k1 = "select * from painvestigation where pid='" + Label1.Text + "'";
cm = new SqlCommand(k1, cn);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cm);
da.Fill(ds);
repeater.DataSource = ds;
repeater.DataBind();
}
}
.aspx code
<asp:GridView ID="GridView4" runat="server" class="table" CssClass="Grid" AutoGenerateColumns="False" Width="100%">
<Columns>
<asp:TemplateField HeaderText="Mid Treatment Images">
<ItemTemplate>
<asp:DataList ID="Repeater2" runat="server" RepeatDirection="Horizontal" CellSpacing="6" CellPadding="4" RepeatColumns="4" Width="100%">
<ItemTemplate>
<div class="col-lg-3a" style="font-family : Calibri">
<img src='/initial/<%# Eval("mid1") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid2") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid3") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid4") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid5") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid6") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid7") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid8") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid9") %>' style="width: 80px; height: 80px;">
<img src='/initial/<%# Eval("mid10") %>' style="width: 80px; height: 80px;">
</div>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
aspx.cs
protected void showmidtreatment()
{
string cs = ConfigurationManager.AppSettings["doctor_DB"];
cn = new SqlConnection(cs);
cn.Open();
string k = "select * from painvestigation where pid='" + Label1.Text + "'";// and status='" + status + "'";
cm = new SqlCommand(k, cn);
dr = cm.ExecuteReader();
GridView4.DataSource = dr;
GridView4.DataBind();
dr.Close();
foreach (GridViewRow gv1 in GridView4.Rows)
{
DataList repeater = (DataList)gv1.Cells[0].FindControl("Repeater2");
string k1 = "select * from painvestigation where pid='" + Label1.Text + "'";
cm = new SqlCommand(k1, cn);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cm);
da.Fill(ds);
repeater.DataSource = ds;
repeater.DataBind();
}
}
single images in grid
aspx code
<asp:GridView ID="GridView6" runat="server" class="table" CssClass="Grid" AutoGenerateColumns="False" Width="100%">
<Columns>
<asp:TemplateField HeaderText="Upload Upper and Lower Impressions Photos">
<ItemTemplate>
<asp:DataList ID="Repeater4" runat="server" RepeatDirection="Horizontal" CellSpacing="6" CellPadding="4" RepeatColumns="4" Width="100%">
<ItemTemplate>
<div class="col-lg-3a" style="font-family : Calibri">
<img src='/initial/<%# Eval("upperlower") %>' style="width: 80px; height: 80px;">
</div>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
.aspx.cs code
protected void showupperlower()
{
string cs = ConfigurationManager.AppSettings["doctor_DB"];
cn = new SqlConnection(cs);
cn.Open();
string k = "select * from painvestigation where pid='" + Label1.Text + "'";// and status='" + status + "'";
cm = new SqlCommand(k, cn);
dr = cm.ExecuteReader();
GridView6.DataSource = dr;
GridView6.DataBind();
dr.Close();
foreach (GridViewRow gv1 in GridView6.Rows)
{
DataList repeater = (DataList)gv1.Cells[0].FindControl("Repeater4");
string k1 = "select * from painvestigation where pid='" + Label1.Text + "'";
cm = new SqlCommand(k1, cn);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cm);
da.Fill(ds);
repeater.DataSource = ds;
repeater.DataBind();
}
}