0
protected void LinkButton1_Click(object sender, EventArgs e)
    {
        try
        {

            int index = 0;

            LinkButton lb = (LinkButton)sender;
            GridViewRow row = (GridViewRow)lb.NamingContainer;
            if (row != null)
            {
                index = row.RowIndex;
            }

            Label labelID = (Label)GridViewNewsFeed.Rows[index].FindControl("HiddenFieldID");
            HiddenField1.Value = labelID.Text;





            SPWeb web = SPContext.Current.Web;

            SPSiteDataQuery query = new SPSiteDataQuery();

            query.Lists = "<Lists>" +
                          "<List ID=" + web.Lists.TryGetList("StaffNews").ID.ToString() + " />" +
                          "<List ID=" + web.Lists.TryGetList("CompanyNews").ID.ToString() + " />" +
                          "<List ID=" + web.Lists.TryGetList("ManagementNews").ID.ToString() + " />" +
                          "</Lists>";
            query.Query = "<Where><Eq><FieldRef Name='ID' /><Value Type='Text'>" + labelID.Text + "</Value></Eq></Where>"; 



            query.ViewFields = "<FieldRef Name=\"Title\" />" + "<FieldRef Name=\"Attachments\" />" +
                               "<FieldRef Name=\"Authors\" />" + "<FieldRef Name=\"Link\" />" +
                               "<FieldRef Name=\"Contents\" />" + "<FieldRef Name=\"Categories\" />" +
                               "<FieldRef Name=\"Date1\" Nullable=\"TRUE\"/>" + "<FieldRef Name=\"UniqueId\"/>";


           query.Webs = "<Webs Scope=\"SiteCollection\" />";

           query.RowLimit = 5;

           DataTable dt = web.GetSiteData(query);

            DataView dv = new DataView(dt);

            DetailsView1.DataSource = dv;
            DetailsView1.DataBind();
        }
        catch (Exception x)
        {
            Label1.Text = x.Message;
        }
    }

i cant get the unique id how should i solve this?

1 Answer 1

2

There is not UniqueId property on the SPList, but rather on the SPListItem, so you should use the ID as it is already unique, being a GUID (http://msdn.microsoft.com/en-us/library/dd587801(v=office.11).aspx)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.