Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#ASP.NET
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 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 5-Nov-12 19:06pm
manognya kota at 6-Nov-12 1:19am
Can you please provide code how you are binding the xml and dataset to the data list?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


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();
            Yourdatalist.DataSource = ds.Tables["table1"].DefaultView;
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.
abhinavashubajpai at 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)

  Print Answers RSS
Your Filters
0 Shai Vashdi 1,628
1 Tadit Dash 375
2 Manas Bhardwaj 319
3 Sergey Alexandrovich Kryukov 275
4 OriginalGriff 243
0 Sergey Alexandrovich Kryukov 9,530
1 OriginalGriff 5,711
2 Peter Leow 4,320
3 Maciej Los 3,540
4 Abhinav S 3,373

Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 6 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid