Set Selected View property programmatically
Windows Server Forum Index Windows Server
Server discussion on Windows platform.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web winserverhelp.com
Set Selected View property programmatically

 
Post new topic   Reply to topic    Windows Server Forum Index -> Portal Server
Author Message
Esperanza
Guest





Posted: Tue Nov 08, 2005 5:51 pm    Post subject: Set Selected View property programmatically Reply with quote

I am try to create a view to filter the documents based in a query to a
database, but my problem is that I cant set this view as default view by
code, please help me.

SPWeb pagina = SPControl.GetContextWeb(Context);

pagina.AllowUnsafeUpdates = true;

SPListCollection librer = pagina.Lists;
foreach(SPList lib in pagina.Lists)
{
if (lib.Title == "Resumen gerencia")
{
SPViewCollection views = list.Views;
string viewName = "VistaNueva1";
System.Collections.Specialized.StringCollection viewFields = new
System.Collections.Specialized.StringCollection();
foreach (SPField campo in list.Fields)
{
viewFields.Add(campo.Title );
}
string query1 ="<Where><Eq><FieldRef Name='Contrato'/><Value
Type='Choice'>MULSEG - Multicontactos Segunda Fase</Value></Eq></Where>";

views.Add(viewName, viewFields, query1, 100, true,true);

}
}

This code create a new view for the list, but how could set this view as
selected view without use Edit page-modify shared webpart. I need to set the
Selected View property of the listviewwebpart programmatically.

Thanks in advance.


--
Esperanza
Back to top
 
Post new topic   Reply to topic    Windows Server Forum Index -> Portal Server All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




New Topics Powered by phpBB