Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.
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("labelGetId");
            HiddenFieldID.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.ViewFields = "<FieldRef Name=\"Title\" />" +
                               "<FieldRef Name=\"Authors\" />" +
                               "<FieldRef Name=\"Link\" />" +
                               "<FieldRef Name=\"Contents\" />" +
                               "<FieldRef Name=\"Categories\" />" +
                               "<FieldRef Name=\"UniqueId\" />" +
                               "<FieldRef Name=\"Date1\" Nullable=\"TRUE\"/>";

            query.Query = "<Where><Eq><FieldRef Name='UniqueId' /><Value Type='Text'>" + labelID.Text +
                          "</Value></Eq></Where>";
            query.Webs = "<Webs Scope=\"SiteCollection\" />";


            DataTable dt = web.GetSiteData(query);
            DataView dv = new DataView(dt);

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

            Label1.Text = x.Message;
        }
    }

// Here on the Linkbutton i am getting the specified UniqueID that i click on in the gridview to display in the detailsview

enter image description here

// i have started with this code to the button for the commentboxes but dont now what to do now.

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>";

enter image description here

share|improve this question

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.