How to display multiple photo in DataList column
THIS FORMAT.
1 2
3 4
user id save in post table and postid save in photo table
create table post(pid int identity(1,1),post_text varchar(max), id int)
create table photo(ph id int identity(1,1),ph_name varchar(100),postid int)
insert into post values(1,'hi',10) -- 3 table record
insert into post values(2,'hello',5)
insert into post values(3,'kya bat hai',10)
insert into post values(4,'kya hall hai',10)
insert into photo values(1,'images/1.jpg',1)
insert into photo values(2,'images/2.jpg',1)
insert into photo values(3,'images/3.jpg',1)
insert into photo values(4,'images/4.jpg',1)
insert into photo values(5,'images/5.jpg',1)
insert into photo values(6,'images/6.jpg',1)
insert into photo values(7,'images/6.jpg',2)
insert into photo values(8,'images/6.jpg',2)
USING SHOWUSER PHOTO
private void show_post()
{
// try
// {
DataSet odt;
odt = IP.showuserpost(Convert.ToInt32(Session["uid"].ToString()));
if (odt != null)
{
if (odt.Tables[0].Rows.Count > 0)
{
Datalistpost.DataSource = odt;
Datalistpost.DataBind();
foreach (DataListItem item in Datalistpost.Items)
{
Image im = item.FindControl("im11") as Image;
if (im.ImageUrl == "")
{
im.Visible = false;
}
else
{
im.Visible = true;
}
}
foreach (DataListItem item in Datalistpost.Items)
{
HtmlGenericControl vdo = item.FindControl("VideoPlayer") as HtmlGenericControl;
// vdo.Attributes["src"] = odt.Tables[0].Rows[i]["video_link"].ToString();
string ak = vdo.Attributes["src"].ToString();
if (ak.ToString() != "")
{
vdo.Visible = true;
}
else
{
vdo.Visible = false;
}
}
}
}
else
{
}
}
public DataSet showuserpost(int uid)
{
Sqlcon();
string qry = "select * from tbluserinfo as p join tbluserprofilepicture t on p.id=t.id"
+ " join post pt on pt.id=p.id"
+ " join tblfrequst tbf on tbf.to_id=p.id"
+ " where tbf.from_id=@id"
+ " UNION "
+ " select * from tbluserinfo as p join tbluserprofilepicture t on p.id=t.id"
+ " join post pt on pt.id=p.id"
+ " join tblfrequst tbf on tbf.from_id=p.id"
+ " where tbf.to_id=@id";
SqlDataAdapter adp = new SqlDataAdapter(qry, con);
adp.SelectCommand.Parameters.Add("@id", SqlDbType.Int, 100).Value = uid;
DataSet ds = new DataSet();
adp.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
return ds;
}
else
{
return null;
}
}
public DataSet showuserphoto(int uid)
{
Sqlcon();
string qry = "select * from tbluserinfo as p join tbluserprofilepicture t on p.id=t.id"
+ " join CREATE_ALBUM pc on pc.U_ID=p.id"
+ " join ALBUM_PHOTO te on te.al_id=pc.AL_ID"
+ " join tblfrequst tbl on tbl.from_id=p.id"
+ " where tbl.to_id=@id"
+ " UNION"
+ " select * from tbluserinfo as p join tbluserprofilepicture t on p.id=t.id"
+ " join CREATE_ALBUM pc on pc.U_ID=p.id"
+ " join ALBUM_PHOTO te on te.al_id=pc.AL_ID"
+ " join tblfrequst tbl on tbl.to_ID=p.id"
+ " where tbl.from_id=@id order by wl_id desc";
SqlDataAdapter adp = new SqlDataAdapter(qry, con);
adp.SelectCommand.Parameters.Add("@id", SqlDbType.Int, 100).Value = uid;
DataSet ds = new DataSet();
adp.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
return ds;
}
else
{
return null;
}
}
}