Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello All

I have a task in which i need to show the images into a data list. Data list already contain some images that are coming through the API of templatemonster.com and I want to add some images from my side into the database and those images should be shown into the same data list.
When I created an xml file and inserted data manually into xml file then it is generating an error because in item template field I am using the path of database field so if any one has a good idea about how to show images from database and xml file together on a single data list then please let me know.
If any body can provide code then it will be appreciated


...Thanks in advance.
Posted
Comments
manognya kota 6-Nov-12 1:19am    
Can you please provide code how you are binding the xml and dataset to the data list?

1 solution

Hi,


As per my understanding you have a dataset from database and one from xml.
If you are getting dataset from the xml and then binding it to datalist like,


DataSet ds = new DataSet();
           ds.ReadXmlSchema(Server.MapPath("XML/CustomersOrders.xsd"));
           ds.ReadXml(Server.MapPath("XML/CustomersOrders.xml"));
           Yourdatalist.DataSource = ds.Tables["table1"].DefaultView;
           Yourdatalist.DataBind();


you can merge the datatables of this 2 and bind it to the datalist.

Sample code for merging data tables

 datatblAll = datatblOne.Copy();
datatblAll .Merge(datatblTwo);


Hope this helps.
 
Share this answer
 
v3
Comments
abhinavashubajpai 6-Nov-12 2:21am    
thanks i got the solution but i am not getting the images that are coming from XML file i am sending my code please have a look...

string sTemplateCategory = ddlCategoryName.SelectedValue == "Select Template Category" ? "" : ddlCategoryName.SelectedValue;
Templatecl oTemplatecl = new Templatecl();
DataTable dtTemplate = oTemplatecl.GetTop20Template(sTemplateTypeName, sTemplateCategory);
dtTemplate.Columns.Add("screen", typeof(bool));
PagedDataSource pdsPaging = new PagedDataSource();
pdsPaging.DataSource = dtTemplate.DefaultView;
//----------------------------------------------------

string sFile = Server.MapPath("/testingdata/Arcstemp.xml");
DataSet odatatable = new DataSet();
odatatable.ReadXml(sFile);
PagedDataSource oPageDataSource = new PagedDataSource();
oPageDataSource.DataSource = odatatable.Tables["image"].DefaultView;
DataTable all = new DataTable();
all = odatatable.Tables["image"].Copy();
all.Merge(dtTemplate);
pdsPaging.DataSource = all.DefaultView;
//----------------------------------------------------------


dlTemplates.DataSource = pdsPaging;
dlTemplates.DataBind();
foreach (DataListItem dl in dlTemplates.Items)
{
string sScreenShotUrl = ((HiddenField)dl.FindControl("hdnScreenShotUrl")).Value;
Panel pnlShadowBox = (Panel)dl.FindControl("pnlShadow");
Panel pnlThumbImg = (Panel)dl.FindControl("pnlThumb");
if (sScreenShotUrl != "")
{
pnlShadowBox.Visible = true;
}
else
{
pnlThumbImg.Visible = true;
}
}

please make modification in the code and let me know thanks ..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900