Pruthvi Patel

Pruthvi Patel

  • NA
  • 129
  • 23.3k

Bind image with radio button(image is fetch from database)?

Mar 20 2016 10:22 AM
Through this code i am getting the images from database and bind it with datalist.
but i want to put radio button ahead of each image how can i do that please help me this is my college project and i have to submit it in a week.
This is my webform :
 
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="diseaseid.aspx.cs" Inherits="project007.diseaseid" %>
<asp:Content ID="Content1" ContentPlaceHolderID="StyleSection" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentSection" runat="server">
<div class="jumbotron">
<asp:DataList ID="DataList1" runat="server" RepeatColumns="3">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# "Handler5.ashx?diseaseid="+ Eval("diseaseid") %>'/>
</ItemTemplate>
</asp:DataList>
<asp:Label ID="Label1" runat="server" Text="?? ????? ???? ??? ? ????? ?? ??? ??? ????? ?????? ??? ?? ??????? ??? ?????."></asp:Label><br />
<asp:Button ID="Button1" CssClass="btn" runat="server" Text="?????? ????" OnClick="Button1_Click" />
</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptSection" runat="server">
</asp:Content>
 
This is my codebehind:
 
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Conn"].ToString());
SqlCommand command = new SqlCommand("SELECT diseaseid,image from [disease_details]", con);
SqlDataAdapter ada = new SqlDataAdapter(command);
DataTable dt = new DataTable();
ada.Fill(dt);
DataList1.DataSource = dt;
DataList1.DataBind();
}
 
This is my handler for fetch image stored in database as image datatype: 
 
public class Handler5 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
try
{
string diseaseid = context.Request.QueryString["diseaseid"];
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ToString());
con.Open();
SqlCommand command = new SqlCommand("select * from disease_details where diseaseid=" + diseaseid, con);
SqlDataReader dr = command.ExecuteReader();
dr.Read();
context.Response.BinaryWrite((byte[])dr["image"]);
con.Close();
context.Response.End();
}
catch (Exception ex)
{
ex.ToString();
}
 
 
 

Answers (1)