SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
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?

share|improve this question

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)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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