| 
                                                                            
                                                                                hemanthray-gmail
                                                                            - 
                                                                                1/24/2011 10:53:19 AM
                                                                            
                                                                         
                                                                        Update a Document type progrmatically 
                                                                            Well we have events where we upload them Programatically. I dint face any issue with Inserting them but I face issue while updating them through code. Can  I please get assistance regarding that thanks.
 Here is the  Code which I have . "2011 Meeting" is a event created under Folder Events but it doenst update it creates a new one can you please let me know what is the issue with the code
 
 #region "Adding Events to Kentico"
 for (i = 0; i < ds.Tables[0].Rows.Count; i++)
 {
 string newsName = ds.Tables[0].Rows["Meeting_Name"].ToString();
 
 // create tree provider instance
 
 CMS.TreeEngine.TreeProvider provider = new CMS.TreeEngine.TreeProvider(CMS.CMSHelper.CMSContext.CurrentUser);
 
 // get parent node for new document
 CMS.TreeEngine.TreeNode parent = provider.SelectSingleNode(CMS.CMSHelper.CMSContext.CurrentSiteName, "/Events", "en-us");
 // create a new tree node
 CMS.TreeEngine.TreeNode node = new TreeNode("CMS.BookingEvent", provider);
 CMS.TreeEngine.TreeNode Childnode = provider.SelectSingleNode(CMS.CMSHelper.CMSContext.CurrentSiteName, "/Events/2011 Meeting", "en-us");
 
 
 if (Childnode != null)
 {
 // Update values
 node.SetValue("EventName", newsName);
 node.SetValue("EventDetails", ds.Tables[0].Rows["Description"].ToString() + "<br/>" + ds.Tables[0].Rows["RegistrationLink"].ToString());
 // Update the document
 Childnode.Update();
 }
 else
 {
 if (parent != null)
 {
 // set document properties
 node.NodeName = ds.Tables[0].Rows["Meeting_Name"].ToString();
 node.NodeAlias = ds.Tables[0].Rows["Meeting_Name"].ToString();
 node.SetValue("DocumentCulture", "en-us");
 node.SetValue("EventName", newsName);
 node.SetValue("EventSummary", ds.Tables[0].Rows["Description"].ToString());
 node.SetValue("EventDetails", ds.Tables[0].Rows["Description"].ToString());
 node.SetValue("EventLocation", ds.Tables[0].Rows["Location"].ToString());
 node.SetValue("EventDate", Convert.ToDateTime(ds.Tables[0].Rows["Start_date"].ToString()));
 node.SetValue("EventOpenFrom", Convert.ToDateTime(ds.Tables[0].Rows["Start_date"].ToString()));
 node.SetValue("EventOpenTo", Convert.ToDateTime(ds.Tables[0].Rows["Start_date"].ToString()));
 
 // create New document
 node.Insert(parent.NodeID);
 }
 }
 
 }
 
 Thanks
 hemanth
 
                                                                            
                                                                         
 
                                                                            
                                                                            
                                                                            
                                                                            
                                                                            
                                                                         
                                                                            
                                                                            
                                                                            
                                                                            
                                                                         
                                                                         |