List Column Connectivity-look up
Hi, I have 2 list training details and training tracking in training details- TrainingName and Modules i created as single line of text in training tracking TrainingAssigned and TotalModules i created as look up when i enter 2 times in training details 1st entry-dot net(training name),modules(10) 2nd entry-moss(training name),module(20) in 2nd list my entriesshud be like that when i choose dot net(training assigned) then for totalmodules column 10 shud come and when i choose moss then 20 shud come(as both column are look up in 2nd list) right now when i choose dot net ..or mos then both (10 20) entries are coming how can i do this logic For your more clarification-as i choose training assigned name(eg dot net) then in totalmodules only those number shud present which someone enter in 1st list (training details) -module column with related training name . help:( i wrote this event handler is it relevant or will it work? using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint; using System.Web; using System.Net.Mail; using System.IO; using System.Data; using System.Xml; using Microsoft.SharePoint.Utilities; using System.Web.UI.WebControls; namespace NewTrainingTrackEventHandling { public class TrainingTrack : SPItemEventReceiver { public HttpContext context; public TrainingTrack() { if (context == null) { context = HttpContext.Current; } } public override void ItemAdding(SPItemEventProperties properties) { SPSite siteurl = new SPSite("http://172.20.14.16/IS/"); SPWeb mySite = siteurl.OpenWeb(); SPList myList = mySite.Lists["Training Tracking"]; SPField ListField = myList.Fields["Training Assigned"]; string classname = "NewTrainingTrackEventHandling.TrainingTrack"; string asmname = "NewTrainingTrackEventHandling,Version=1.0.0.0,culture=neutral, PublicKeyToken=d766c22041c04c60"; myList.EventReceivers.Add(SPEventReceiverType.ItemAdding, asmname ,classname); String strViewName = "AllItems.aspx"; SPView view = properties.OpenWeb().GetViewFromUrl("Lists/Training%20Tracking/" + strViewName); SPListItemCollection collListItems = myList.GetItems(view); if (collListItems.Count == 0 && collListItems.Count == 1)//Always true { ListField.ShowInNewForm = true; //show in new form (newform.aspx)//{this line or below line both for reaching at Newform.aspx} context.Response.Redirect("/IS/Lists/Training%20Tracking/NewForm.aspx"); string trainingAssigned =""; string totalModules =""; SPList mylist = SPContext.Current.Web.Lists["Training Details"]; SPQuery query = new SPQuery(); //this query will pur value of Training Name Field into training Assigned variable query.Query = "<Where><Eq><FieldRef Name='Training Name'/><Value Type='Text'>" + trainingAssigned + "</Value></Eq></Where>"; //SPListItem item = list.GetItems(query)[0]; SPListItemCollection items = mylist.GetItems(query); SPListItem nitem = items[0]; totalModules = Convert.ToString(nitem["Modules"]); } } } } sudhanshu sharma
August 18th, 2011 5:04pm

Rahul is right. You do not have to use SPD. You can create a usercontrol and deploy as a webpart with dll in GAC. The usercontrol can imitate your newform.aspx. You can also change the url for your New Item button on your list using SPD. Take a look at this thread. You can change it to the URL where you custom form exists. Thanks, GeeVed
Free Windows Admin Tool Kit Click here and download it now
August 24th, 2011 6:48pm

Hi All, i wrote a event handle with class library when in portal someone open list Training Tracking and click newitem we reach at NewForm.aspx can i write event handling for this NewForm.aspx See My COde and suggest can we do like this- namespace NewTrainingTrackEventHandling { public class TrainingTrack : SPItemEventReceiver { public HttpContext context; public TrainingTrack() { if (context == null) { context = HttpContext.Current; } } public override void ItemAdding(SPItemEventProperties properties) { SPSite collections = new SPSite("http://172.20.14.16/IS/"); SPWeb mySite = collections.OpenWeb(); SPList incidentList = mySite.Lists["Training Tracking"]; string classname = "NewTrainingTrackEventHandling.TrainingTrack"; string asmname = "NewTrainingTrackEventHandling,Version=1.0.0.0,culture=neutral, PublicKeyToken=d766c22041c04c60"; incidentList.EventReceivers.Add(SPEventReceiverType.ItemAdding, asmname ,classname); String strViewName = "AllItems.aspx"; SPView view = properties.OpenWeb().GetViewFromUrl("Lists/Training%20Tracking/" + strViewName); SPListItemCollection collListItems = incidentList.GetItems(view); if (collListItems.Count == 0 && collListItems.Count == 1)//Always true { context.Response.Redirect("/IS/Lists/Training%20Tracking/NewForm.aspx"); string trainingAssigned = ""; string totalModules = string.Empty; SPList mylist = SPContext.Current.Web.Lists["Training Details"]; SPQuery query = new SPQuery(); query.Query = "<Where><Eq><FieldRef Name='Training Name'/><Value Type='Text'>" + trainingAssigned + "</Value></Eq></Where>"; //SPListItem item = list.GetItems(query)[0]; SPListItemCollection items = mylist.GetItems(query); SPListItem nitem = items[0]; totalModules = Convert.ToString(nitem["Modules"]); Please suggest ..its going to be very difficult:( how this event handler will be connect wid my portal list bydefault NewForm.aspx :( sudhanshu sharma
August 25th, 2011 2:49am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics