Esperanza
Guest
|
Posted:
Tue Nov 08, 2005 5:51 pm Post subject:
Set Selected View property programmatically |
|
|
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 |
|