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

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