Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

enter image description here

 protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {

            if (DropDownListFeeds.SelectedItem.Value == "All")
            {
                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=\"Date\" Nullable=\"TRUE\"/>";
                query.Query = "<OrderBy><FieldRef Name='Modified' Ascending='FALSE'></FieldRef></OrderBy>";
                query.Webs = "<Webs Scope=\"SiteCollection\" />";

                query.RowLimit = 10;

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



                GridViewNewsFeed.DataSource = dv;
                GridViewNewsFeed.DataBind();



            }
        }

        catch (Exception x)
        {

            Label1.Text = x.Message;
        }

    }

Abowe Date and Title i have a Dropdownlist and a Button the code above are for the button.

the code for what happens when i press linkbutton in the first grinview and display it in the other grindview looks like this.

protected void LinkButton1_Click(object sender, EventArgs e)
    {


        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=\"Links\" />"+"<FieldRef Name=\"Contents\" />"+
                           "<FieldRef Name=\"Date\" Nullable=\"TRUE\"/>";
        query.Query = "<OrderBy><FieldRef Name='Modified' Ascending='FALSE'></FieldRef></OrderBy>";
        query.Webs = "<Webs Scope=\"SiteCollection\" />";

        query.RowLimit = 10;

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



        GridViewShowMore.DataSource = dv;
        GridViewNewsFeed.DataBind();


    }
share|improve this question
add comment

1 Answer

This is a ASP.Net Question more than a Sharepoint one. You dont have to use Connected web parts as that is used for something completely different. (Passing rows of data using a consumber/subcriber type of model).

Anyways, coupld of ways to do this, and the shortest would be:

<asp:LinkButton Text="text" runat="server" ID="LinkButton1" 
    onclick="LinkButton1_Click" />   

protected void LinkButton1_Click(object sender, EventArgs e)
{
    TypeOfYourOtherWebpart Ctrl = this.Page.FindControl("YourOtherControlID") as TypeOfYourOtherWebpart;
    TypeOfYourOtherWebpart.MyData = "SomeValue";
}
share|improve this answer
    
Thanks! But what are SharePoint built on?Maybe asp?? –  Martin Jan 31 '13 at 11:29
    
and by the way , do i not need any Consumer or Provider , so what should i use? I Dont get it... –  Martin Jan 31 '13 at 11:32
    
ASP.Net 3.5. The way i showed above will find the Control on the page (all web parts on the page). I would however suggest that you just use 1 web part. That way you wouldn't have to do a FindControl and could just reference by its name. –  Fox Jan 31 '13 at 11:38
    
i want only my linkbutton to get and set the property data , i dont get it to work, i have upaded my image in the top –  Martin Jan 31 '13 at 12:31
    
i want my linkbutton to use property MyData –  Martin Jan 31 '13 at 12:38
show 7 more comments

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.