Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

copy each of link of a library in c# loop

$
0
0

Hi,

I want to join 3 libraries in a grid-view.

I did it but only texts were copied and pasted in new grid-view. 

Can anybody tell me how can I get link  of each row?  Here is my code:

        protected override void CreateChildControls()
        {
            try
            {
                var list = SPContext.Current.Web.GetList(SPUrlUtility.CombineUrl(SPContext.Current.Web.ServerRelativeUrl, fldListUrl1));

                var gv = new SPGridView();
                gv.AutoGenerateColumns = false;
                gv.EnableViewState = false;

                foreach (string vwfield in list.DefaultView.ViewFields)
                {
                    SPField field = list.Fields.GetFieldByInternalName(vwfield);

                    if (field.Hidden == false)
                    {
                        BoundField boundField = new BoundField();
                        boundField.HeaderText = field.Title;
                        boundField.DataField = field.InternalName;
                        gv.Columns.Add(boundField);
                    }
                }

                var dt = list.GetItems().GetDataTable();
                var list2 = SPContext.Current.Web.GetList(SPUrlUtility.CombineUrl(SPContext.Current.Web.ServerRelativeUrl, fldListUrl2));
                var dt2 = list2.GetItems().GetDataTable();

                foreach (DataRow r in dt2.Rows)
                {
                    var row = dt.NewRow();
                    foreach (DataColumn c in dt.Columns)
                    {
                        row[c.ColumnName] = r[c.ColumnName];
                    }
                    dt.Rows.Add(row);
                }

                gv.DataSource = dt;
                gv.DataBind();
                Controls.Add(gv);
            }
            catch (Exception e)
            {
                Controls.Add(new LiteralControl(e.ToString()));
            }
        }
Thanks for your help


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>