Search Results

Search found 275 results on 11 pages for 'listitem'.

Page 11/11 | < Previous Page | 7 8 9 10 11 

  • Enforce link in Team foundation server bug work item for duplicates

    - by Tewr
    We have just started out with Team Foundation Server 2008 / Visual Studio Team System and we are pleased to find how we can export and modify work items to our needs. However, this last thing that would make the setup perfect for us has proved somewhat difficult: We have exported the Bug work item type and have made modifications to it to appear differently to different groups of users. We do, however, see a potential problem in non-developers reporting bugs which turn out to be duplicates. We would like to enforce that users who close a ticket with resolved reason:duplicate also creates a link to the bug which is perceived as the first bug report. I have looked at System.RelatedLinkCount, and put the rule <FIELD type="Integer" name="RelatedLinkCount" refname="System.RelatedLinkCount"> <WHEN field="Microsoft.VSTS.Common.ResolvedReason" value="duplicate"> <PROHIBITEDVALUES> <LISTITEM value="0" /> </PROHIBITEDVALUES> </WHEN> </FIELD> However, when I try to put anything in that scope, the importer tells me that System.RelatedLinkCount does not accept the rule, no matter what I put, but the rule above shows what I am trying to do (even though the most preferable rule would also check that the bug that I link to is not a duplicate as well, though this is overkill :P) Has anyone else tried to enforce rules like this in work items? Is there another approach to solving the same issue? I am thankful for any thoughts on the matter.

    Read the article

  • JQuery going through a set of UL and dynamically set ids incremently on each one

    - by Calibre2010
    I have an unordered list which contains serveral items called 'oListItems' the UL has a class but no id. The class OuteroListItems contains many of oListitems oList.AppendFormat("<ul class='OuteroListItems'>"); oList.AppendFormat("<li>"); oList.AppendFormat("<ul class='oListItems'>"); oList.AppendFormat("<li>" + s.sName + "</li>"); oList.AppendFormat("<li>" + s.eName + "</li>"); oList.AppendFormat("<li>" + s.SDate + "</li>"); oList.AppendFormat("<li>" + s.EDate + "</li>"); oList.AppendFormat("</ul>"); oList.AppendFormat("</li>"); oList.AppendFormat("</ul>"); I want for each .oListItem class that gets retrieved, add dynamically an id to it. var o = $(".oListItem"); $.each(o, function (){ var f = $(this).attr("id", 'listItem' + i); i++; }); wasent sure on the approach, this is what I have so far?

    Read the article

  • Scroll to item in listview in Silverlight 3.

    - by the empirical programmer
    I have a silverlight 3 app with a textbox on the main window and a childwindow that has a list of all the potential textbox values. When I open that childwindow I want it to scroll to the correct one in the list. I'm trying to do this with the code below...using the ScrollIntoView. It was not working at all until I add the UpdateLayerout(). However it does not seem to work all the time. At times it scrolls but not all the way to the item, it is a few items higher than it should be. The listbox is in an Accordion and the list items use a ItemTemplate\DataTemplate, not sure if that effects anything but thought I'd mention it. Any ideas what I'm missing in the code below? What I would like is to scroll the item to the top of the list ....any ideas how to that? (Or any other suggestions on how to code this better) Thanks! for (int index = 0; index < myList.Items.Count; index++) { object obj = myList.Items[index]; var listItem= obj as listItemObject; if (listItemObj != null) { if (string.Compare(listItemObj.id, _PastedInId, StringComparison.InvariantCultureIgnoreCase) == 0) { selectThisIndex = index; scrollToThisItem = obj; } } } myList.SelectedIndex = selectThisIndex; if (scrollToThisItem != null){ myList.UpdateLayout(); myList.ScrollIntoView(scrollToThisItem); }

    Read the article

  • Create a new site programmatically and select parent site? (SharePoint)

    - by peter
    Hi, I am using the following code to create a new site: newWeb = SPContext.GetContext(HttpContext.Current).Web.Webs.Add(newSiteUrl, newSiteName, null, (uint)1033, siteTemplate, true, false); try { newWeb.Update(); } NewSiteUrl and newSiteName are values from two textboxes and on whichever site I use this code (in a web part) the new site will be a subsite to this site. I would now like to be able to select a parent site so that the new site can sit anywhere in the site collection, not just as a subsite to the site where I use the web part. I created the following function to get all the sites in the site collection and populate a drop down with the name and url for every site private void getSites() { SPSite oSiteCollection = SPContext.Current.Site; SPWebCollection collWebsite = oSiteCollection.AllWebs; for (int i = 0; i < collWebsite.Count; i++) { ddlParentSite.Items.Add(new ListItem(collWebsite[i].Title, collWebsite[i].Url)); } oSiteCollection.Dispose(); } If the user selects a site in the dropdown, is it possible to use that URL in newSiteUrl so decide where the new site should be? I don't get it to work really and the new site still becomes a subsite to the current one. I guess it has to do with HttpContext.Current? Any ideas on how I should do it instead? It's the first time I write custom web parts and the sharepoint object model is a bit overwhelming at the moment. Thanks in advance.

    Read the article

  • Styling ASP.NET MVC Error Messages

    - by MightyZot
    Originally posted on: http://geekswithblogs.net/MightyZot/archive/2013/11/11/styling-asp.net-mvc-error-messages.aspxOff the cuff, it may look like you’re stuck with the presentation of your error messages (model errors) in ASP.NET MVC. That’s not the case, though. You actually have quite a number of options with regard to styling those boogers. Like many of the helpers in MVC, the Html.ValidationMessageFor helper has multiple prototypes. One of those prototypes lets you pass a dictionary, or anonymous object, representing attribute values for the resulting markup. @Html.ValidationMessageFor( m => Model.Whatever, null, new { @class = “my-error” }) By passing the htmlAttributes parameter, which is the last parameter in the call to the prototype of Html.ValidationMessageFor shown above, I can style the resulting markup by associating styles to the my-error css class.  When you run your MVC project and view the source, you’ll notice that MVC adds the class field-validation-valid or field-validation-error to a span created by the helper. You could actually just style those classes instead of adding your own…it’s really up to you. Now, what if you wanted to move that error message around? Maybe you want to put that error message in a box or a callout. How do you do that? When I first started using MVC, it didn’t occur to me that the Html.ValidationMessageFor helper just spits out a little bit of markup. I wanted to put the error messages in boxes with white backgrounds, our site originally had a black background, and show a little nib on the side to make them look like callouts or conversation bubbles. Not realizing how much freedom there is in the styling and markup, and after reading someone else’s post, I created my own version of the ValidationMessageFor helper that took out the span and replaced it with divs. I styled the divs to produce the effect of a popup box and had a lot of trouble with sizing and such. That’s a really silly and unnecessary way to solve this problem. If you want to move your error messages around, all you have to do is move the helper. MVC doesn’t appear to care where you put it, which makes total sense when you think about it. Html.ValidationMessageFor is just spitting out a little markup using a little bit of reflection on the name you’re passing it. All you’ve got to do to style it the way you want it is to put it in whatever markup you desire. Take a look at this, for example… <div class=”my-anchor”>@Html.ValidationMessageFor( m => Model.Whatever )</div> @Html.TextBoxFor(m => Model.Whatever) Now, given that bit of HTML, consider the following CSS… <style> .my-anchor { position:relative; } .field-validation-error {    background-color:white;    border-radius:4px;    border: solid 1px #333;    display: block;    position: absolute;    top:0; right:0; left:0;    text-align:right; } </style> The my-anchor class establishes an anchor for the absolutely positioned error message. Now you can move the error message wherever you want it relative to the anchor. Using css3, there are some other tricks. For example, you can use the :not(:empty) selector to select the span and apply styles based upon whether or not the span has text in it. Keep it simple, though. Moving your elements around using absolute positioning may cause you issues on devices with screens smaller than your standard laptop or PC. While looking for something else recently, I saw someone asking how to style the output for Html.ValidationSummary.  Html.ValidationSummery is the helper that will spit out a list of property errors, general model errors, or both. Html.ValidationSummary spits out fairly simple markup as well, so you can use the techniques described above with it also. The resulting markup is a <ul><li></li></ul> unordered list of error messages that carries the class validation-summary-errors In the forum question, the user was asking how to hide the error summary when there are no errors. Their errors were in a red box and they didn’t want to show an empty red box when there aren’t any errors. Obviously, you can use the css3 selectors to apply different styles to the list when it’s empty and when it’s not empty; however, that’s not support in all browsers. Well, it just so happens that the unordered list carries the style validation-summary-valid when the list is empty. While the div rendered by the Html.ValidationSummary helper renders a visible div, containing one invisible listitem, you can always just style the whole div with “display:none” when the validation-summary-valid class is applied and make it visible when the validation-summary-errors class is applied. Or, if you don’t like that solution, which I like quite well, you can also check the model state for errors with something like this… int errors = ViewData.ModelState.Sum(ms => ms.Value.Errors.Count); That’ll give you a count of the errors that have been added to ModelState. You can check that and conditionally include markup in your page if you want to. The choice is yours. Obviously, doing most everything you can with styles increases the flexibility of the presentation of your solution, so I recommend going that route when you can. That picture of the fat guy jumping has nothing to do with the article. That’s just a picture of me on the roof and I thought it was funny. Doesn’t every post need a picture?

    Read the article

  • Linq to sql C# updating reference Tables

    - by Laurence Burke
    ok reclarification I am adding a new address and I know the structure as AddressID = PK and all other entities are non nullable. Now on insert of a new row the addrID Pk is autogened and I am wondering if I would have to get that to create a new row in the referencing table or does that automatically get generated also. also I want to be able to repopulate the dropdownlist that lists the current employee's addresses with the newly created address. static uint _curEmpID; protected void btnAdd_Click(object sender, EventArgs e) { if (txtZip.Text != "" && txtAdd1.Text != "" && txtCity.Text != "") { TestDataClassDataContext dc = new TestDataClassDataContext(); Address addr = new Address() { AddressLine1 = txtAdd1.Text, AddressLine2 = txtAdd2.Text, City = txtCity.Text, PostalCode = txtZip.Text, StateProvinceID = Convert.ToInt32(ddlState.SelectedValue) }; dc.Addresses.InsertOnSubmit(addr); lblSuccess.Visible = true; lblErrMsg.Visible = false; dc.SubmitChanges(); // // TODO: add reference from new address to CurEmp Table // SetAddrList(); } else { lblErrMsg.Text = "Invalid Input"; lblErrMsg.Visible = true; } } protected void ddlAddList_SelectedIndexChanged(object sender, EventArgs e) { lblErrMsg.Visible = false; lblSuccess.Visible = false; TestDataClassDataContext dc = new TestDataClassDataContext(); dc.ObjectTrackingEnabled = false; if (ddlAddList.SelectedValue != "-1") { var addr = (from a in dc.Addresses where a.AddressID == Convert.ToInt32(ddlAddList.SelectedValue) select a).FirstOrDefault(); txtAdd1.Text = addr.AddressLine1; txtAdd2.Text = addr.AddressLine2; txtCity.Text = addr.City; txtZip.Text = addr.PostalCode; ddlState.SelectedValue = addr.StateProvinceID.ToString(); btnSubmit.Visible = true; btnAdd.Visible = false; } else { txtAdd1.Text = ""; txtAdd2.Text = ""; txtCity.Text = ""; txtZip.Text = ""; btnAdd.Visible = true; btnSubmit.Visible = false; } } protected void SetAddrList() { TestDataClassDataContext dc = new TestDataClassDataContext(); dc.ObjectTrackingEnabled = false; var addList = from addr in dc.Addresses from eaddr in dc.EmployeeAddresses where eaddr.EmployeeID == _curEmpID && addr.AddressID == eaddr.AddressID select new { AddValue = addr.AddressID, AddText = addr.AddressID, }; ddlAddList.DataSource = addList; ddlAddList.DataValueField = "AddValue"; ddlAddList.DataTextField = "AddText"; ddlAddList.DataBind(); ddlAddList.Items.Add(new ListItem("<Add Address>", "-1")); } OK I am hoping that I did not include too much code. I would really appreciate any other comments about I could otherwise improve this code in any other ways also.

    Read the article

  • Adding rows with linq trouble with reference table

    - by Laurence Burke
    I am adding a new address and I know the structure as AddressID = PK and all other entities are non nullable. Now on insert of a new row the addrID Pk is autogened and I am wondering if I would have to get that to create a new row in the referencing table EmployeeAddress or does that automatically get generated also. also I want to be able to repopulate the dropdownlist that lists the current employee's addresses with the newly created address. static uint _curEmpID; protected void btnAdd_Click(object sender, EventArgs e) { if (txtZip.Text != "" && txtAdd1.Text != "" && txtCity.Text != "") { TestDataClassDataContext dc = new TestDataClassDataContext(); Address addr = new Address() { AddressLine1 = txtAdd1.Text, AddressLine2 = txtAdd2.Text, City = txtCity.Text, PostalCode = txtZip.Text, StateProvinceID = Convert.ToInt32(ddlState.SelectedValue) }; dc.Addresses.InsertOnSubmit(addr); lblSuccess.Visible = true; lblErrMsg.Visible = false; dc.SubmitChanges(); // // TODO: insert new row in EmployeeAddress to reference CurEmp to newly created address // SetAddrList(); } else { lblErrMsg.Text = "Invalid Input"; lblErrMsg.Visible = true; } } protected void ddlAddList_SelectedIndexChanged(object sender, EventArgs e) { lblErrMsg.Visible = false; lblSuccess.Visible = false; TestDataClassDataContext dc = new TestDataClassDataContext(); dc.ObjectTrackingEnabled = false; if (ddlAddList.SelectedValue != "-1") { var addr = (from a in dc.Addresses where a.AddressID == Convert.ToInt32(ddlAddList.SelectedValue) select a).FirstOrDefault(); txtAdd1.Text = addr.AddressLine1; txtAdd2.Text = addr.AddressLine2; txtCity.Text = addr.City; txtZip.Text = addr.PostalCode; ddlState.SelectedValue = addr.StateProvinceID.ToString(); btnSubmit.Visible = true; btnAdd.Visible = false; } else { txtAdd1.Text = ""; txtAdd2.Text = ""; txtCity.Text = ""; txtZip.Text = ""; btnAdd.Visible = true; btnSubmit.Visible = false; } } protected void SetAddrList() { TestDataClassDataContext dc = new TestDataClassDataContext(); dc.ObjectTrackingEnabled = false; var addList = from addr in dc.Addresses from eaddr in dc.EmployeeAddresses where eaddr.EmployeeID == _curEmpID && addr.AddressID == eaddr.AddressID select new { AddValue = addr.AddressID, AddText = addr.AddressID, }; ddlAddList.DataSource = addList; ddlAddList.DataValueField = "AddValue"; ddlAddList.DataTextField = "AddText"; ddlAddList.DataBind(); ddlAddList.Items.Add(new ListItem("<Add Address>", "-1")); } OK I am hoping that I did not include too much code. I would really appreciate any other comments about I could otherwise improve this code in any other ways also.

    Read the article

  • Passing Data of WebView to Another Activity

    - by meygraph
    I've designed a training program and Html texts and image put into training. I want to address my html file by an activity to sent another activity. This is MainActivity /* * ListView item click listener. So we'll have the do stuff on click of * our ListItem */ listViewArticles.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: Intent newActivity0 = new Intent(TrickPage.this,a_Dotted_Lines.class); startActivity(newActivity0); break; case 1: Intent newActivity1 = new Intent(TrickPage.this,TutorialsPage.class); startActivity(newActivity1); break; case 2: Intent newActivity2 = new Intent(TrickPage.this,TutorialsPage.class); startActivity(newActivity2); break; case 3: Intent newActivity3 = new Intent(TrickPage.this,TutorialsPage.class); startActivity(newActivity3); break; default: // Nothing do! } and this SecondActivity (show WebView) public class a_Dotted_Lines extends Activity { private WebView webView; @SuppressLint("SetJavaScriptEnabled") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.a_dotted_lines); // Button HOME ImageButton ImageButton_home = (ImageButton) findViewById(R.id.ImageButton_home); ImageButton_home.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(a_Dotted_Lines.this, Main.class); startActivity(intent); overridePendingTransition(R.anim.fadein, R.anim.fadeout); } }); //Button Previous ImageButton ImageButton_previus = (ImageButton) findViewById(R.id.ImageButton_previus); ImageButton_previus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Closing SecondScreen Activity finish(); } }); webView = (WebView) findViewById(R.id.webview_compontent); webView.getSettings().setJavaScriptEnabled(true); webView.loadUrl("file:///android_asset/html/article.htm"); } } I want Send "file:///android_asset/html/article.htm" or other addres from MainActivity Is it possible? Sorry My English is not good

    Read the article

  • invalid postback event instead of dropdown to datagrid

    - by rima
    I faced with funny situation. I created a page which is having some value, I set these value and control my post back event also. The problem is happening when I change a component index(ex reselect a combobox which is not inside my datagrid) then I dont know why without my page call the Page_Load it goes to create a new row in grid function and all of my parameter are null! I am just receiving null exception. So in other word I try to explain the situation: when I load my page I am initializing some parameter. then everything is working fine. in my page when I change selected item of my combo box, page suppose to go and run function related to that combo box, and call page_load, but it is not going there and it goes to rowcreated function. I am trying to illustrate part of my page. Please help me because I am not receiving any error except null exception and it triger wrong even which seems so complicated for me. public partial class W_CM_FRM_02 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack && !loginFail) return; InitializeItems(); } } private void InitializeItems() { cols = new string[] { "v_classification_code", "v_classification_name" }; arrlstCMMM_CLASSIFICATION = (ArrayList)db.Select(cols, "CMMM_CLASSIFICATION", "v_classification_code <> 'N'", " ORDER BY v_classification_name"); } } protected void DGV_RFA_DETAILS_RowCreated(object sender, GridViewRowEventArgs e) { //db = (Database)Session["oCon"]; foreach (DataRow dr in arrlstCMMM_CLASSIFICATION) ((DropDownList)DGV_RFA_DETAILS.Rows[index].Cells[4].FindControl("OV_RFA_CLASSIFICATION")).Items.Add(new ListItem(dr["v_classification_name"].ToString(), dr["v_classification_code"].ToString())); } protected void V_CUSTOMER_SelectedIndexChanged(object sender, EventArgs e) { if (V_CUSTOMER.SelectedValue == "xxx" || V_CUSTOMER.SelectedValue == "ddd") V_IMPACTED_FUNCTIONS.Enabled = true; } } my form: <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="W_CM_FRM_02.aspx.cs" Inherits="W_CM_FRM_02" Title="W_CM_FRM_02" enableeventvalidation="false" EnableViewState="true"%> <td>Project name*</td> <td><asp:DropDownList ID="V_CUSTOMER" runat="server" AutoPostBack="True" onselectedindexchanged="V_CUSTOMER_SelectedIndexChanged" /></td> <td colspan = "8"> <asp:GridView ID="DGV_RFA_DETAILS" runat="server" ShowFooter="True" AutoGenerateColumns="False" CellPadding="1" ForeColor="#333333" GridLines="None" OnRowDeleting="grvRFADetails_RowDeleting" Width="100%" Style="text-align: left" onrowcreated="DGV_RFA_DETAILS_RowCreated"> <RowStyle BackColor="#FFFBD6" ForeColor="#333333" /> <Columns> <asp:BoundField DataField="ON_RowNumber" HeaderText="SNo" /> <asp:TemplateField HeaderText="RFA/RAD/Ticket No*"> <ItemTemplate> <asp:TextBox ID="OV_RFA_NO" runat="server" Width="120"></asp:TextBox> </ItemTemplate> </asp:TemplateField>

    Read the article

  • Custom cell in list in Flash AS3

    - by Stian Flatby
    I am no expert in Flash, and I need some quick help here, without needing to learn everything from scratch. Short story, I have to make a list where each cell contains an image, two labels, and a button. List/Cell example: img - label - label - button img - label - label - button As a Java-programmer, I have tried to quicly learn the syntax and visualness of Flash and AS3, but with no luck so far. I have fairly understood the basics of movie clips etc. I saw a tutorial on how to add a list, and add some text to it. So I dragged in a list, and in the code went list.addItem({label:"hello"}); , and that worked ofc. So i thought if I double-clicked the MC of the list, i would get to tweak some things. In there I have been wandering around different halls of cell-renderers etc. I have now come to the point that I entered the CellRenderer_skinUp or something, and customized it to my liking. When this was done, I expected i could use list.addItem(); and get an empty "version" of my cell, with the img, labels and the button. But AS3 expects an input in addItem. From my object-oriented view, I am thinking that i have to create an object of the cell i have made, but i have no luck reaching it.. I tried to go var test:CellRenderer = list.listItem; list.addItem(test); ..But with no luck. This is just for funsies, but I really want to make this work, however not so much that I am willing to read up on ALOT of Flash and AS3. I felt that I was closing in on the prize, but the compiler expected a semicolon after the variable (list.addItem({test:something});). Note: If possible, I do NOT want this: list.addItem({image:"src",label:"text",label"text",button:"text"}); Well.. It actually is what I want, but I would really like to custom-draw everything. Does anyone get what I am trying to do, and has any answers for me? Am I approaching this the wrong way? I have searched the interwebs for custom list-cells, but with no luck. Please, any guiding here is appreciated! Sti

    Read the article

  • How to add a title attribute to every option of an ASP.NET DropDownList

    - by zuallauz
    I'm working on an older ASP.NET project (not MVC I don't think) and one of the features they require is to view a description of an item when they hover over that item in a dropdown list. This can be simply done with HTML using the following code and making use of title text: <select> <option value="1" title="Option 1 Desc">Option 1</option> <option value="2" title="Option 2 Desc">Option 2</option> <option value="3" title="Option 3 Desc">Option 3</option> </select> Ok so how do I do this using ASP.NET DropDownList control? I have the following code: <asp:DropDownList ID="DropDownListLocation" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownListLocation_OnSelectedIndexChanged" CssClass="editorFieldServerControl" ClientIDMode="Static"></asp:DropDownList> And in the 'code behind' page: private void PopulateFacilityDropdown(List<FacilityAvailableByLocation> facilities, int? selectedID) { DropDownListFacility.DataSource = facilities; DropDownListFacility.DataTextField = "FacilityName"; DropDownListFacility.DataValueField = "FacilityID"; DropDownListFacility.DataBind(); DropDownListFacility.Items.Insert(0, new System.Web.UI.WebControls.ListItem("", "")); if (selectedID.HasValue && selectedID.Value > 0) DropDownListFacility.SelectedIndex = facilities.FindIndex(b => b.FacilityID == selectedID.Value); else DropDownListFacility.SelectedIndex = 0; } } Basically each facility in the list of facilities there has properties for an ID, Name, Description that I can get out. I just want to be able to put a title attribute on each <option> that gets rendered and put the description into it. Either that or be able to add a custom attribute like 'data-description' to each <option> tag then I can add the title into each option tag myself using a bit of jQuery which is easy enough. I miss the days where you could just loop through a list and output the custom dropdown code manually. Any ideas? Many thanks

    Read the article

  • Changing CSS with jQuery syntax in Silverlight using jLight

    - by Timmy Kokke
    Lately I’ve ran into situations where I had to change elements or had to request a value in the DOM from Silverlight. jLight, which was introduced in an earlier article, can help with that. jQuery offers great ways to change CSS during runtime. Silverlight can access the DOM, but it isn’t as easy as jQuery. All examples shown in this article can be looked at in this online demo. The code can be downloaded here.   Part 1: The easy stuff Selecting and changing properties is pretty straight forward. Setting the text color in all <B> </B> elements can be done using the following code:   jQuery.Select("b").Css("color", "red");   The Css() method is an extension method on jQueryObject which is return by the jQuery.Select() method. The Css() method takes to parameters. The first is the Css style property. All properties used in Css can be entered in this string. The second parameter is the value you want to give the property. In this case the property is “color” and it is changed to “red”. To specify which element you want to select you can add a :selector parameter to the Select() method as shown in the next example.   jQuery.Select("b:first").Css("font-family", "sans-serif");   The “:first” pseudo-class selector selects only the first element. This example changes the “font-family” property of the first <B></B> element to “sans-serif”. To make use of intellisense in Visual Studio I’ve added a extension methods to help with the pseudo-classes. In the example below the “font-weight” of every “Even” <LI></LI> is set to “bold”.   jQuery.Select("li".Even()).Css("font-weight", "bold");   Because the Css() extension method returns a jQueryObject it is possible to chain calls to Css(). The following example show setting the “color”, “background-color” and the “font-size” of all headers in one go.   jQuery.Select(":header").Css("color", "#12FF70") .Css("background-color", "yellow") .Css("font-size", "25px");   Part 2: More complex stuff In only a few cases you need to change only one style property. More often you want to change an entire set op style properties all in one go.  You could chain a lot of Css() methods together. A better way is to add a class to a stylesheet and define all properties in there. With the AddClass() method you can set a style class to a set of elements. This example shows how to add the “demostyle” class to all <B></B> in the document.   jQuery.Select("b").AddClass("demostyle");   Removing the class works in the same way:   jQuery.Select("b").RemoveClass("demostyle");   jLight is build for interacting with to the DOM from Silverlight using jQuery. A jQueryObjectCss object can be used to define different sets of style properties in Silverlight. The over 60 most common Css style properties are defined in the jQueryObjectCss class. A string indexer can be used to access all style properties ( CssObject1[“background-color”] equals CssObject1.BackgroundColor). In the code below, two jQueryObjectCss objects are defined and instantiated.   private jQueryObjectCss CssObject1; private jQueryObjectCss CssObject2;   public Demo2() { CssObject1 = new jQueryObjectCss { BackgroundColor = "Lime", Color="Black", FontSize = "12pt", FontFamily = "sans-serif", FontWeight = "bold", MarginLeft = 150, LineHeight = "28px", Border = "Solid 1px #880000" }; CssObject2 = new jQueryObjectCss { FontStyle = "Italic", FontSize = "48", Color = "#225522" }; InitializeComponent(); }   Now instead of chaining to set all different properties you can just pass one of the jQueryObjectCss objects to the Css() method. In this case all <LI></LI> elements are set to match this object.   jQuery.Select("li").Css(CssObject1); When using the jQueryObjectCss objects chaining is still possible. In the following example all headers are given a blue backgroundcolor and the last is set to match CssObject2.   jQuery.Select(":header").Css(new jQueryObjectCss{BackgroundColor = "Blue"}) .Eq(-1).Css(CssObject2);   Part 3: The fun stuff Having Silverlight call JavaScript and than having JavaScript to call Silverlight requires a lot of plumbing code. Everything has to be registered and strings are passed back and forth to execute the JavaScript. jLight makes this kind of stuff so easy, it becomes fun to use. In a lot of situations jQuery can call a function to decide what to do, setting a style class based on complex expressions for example. jLight can do the same, but the callback methods are defined in Silverlight. This example calls the function() method for each <LI></LI> element. The callback method has to take a jQueryObject, an integer and a string as parameters. In this case jLight differs a bit from the actual jQuery implementation. jQuery uses only the index and the className parameters. A jQueryObject is added to make it simpler to access the attributes and properties of the element. If the text of the listitem starts with a ‘D’ or an ‘M’ the class is set. Otherwise null is returned and nothing happens.   private void button1_Click(object sender, RoutedEventArgs e) { jQuery.Select("li").AddClass(function); }   private string function(jQueryObject obj, int index, string className) { if (obj.Text[0] == 'D' || obj.Text[0] == 'M') return "demostyle"; return null; }   The last thing I would like to demonstrate uses even more Silverlight and less jLight, but demonstrates the power of the combination. Animating a style property using a Storyboard with easing functions. First a dependency property is defined. In this case it is a double named Intensity. By handling the changed event the color is set using jQuery.   public double Intensity { get { return (double)GetValue(IntensityProperty); } set { SetValue(IntensityProperty, value); } }   public static readonly DependencyProperty IntensityProperty = DependencyProperty.Register("Intensity", typeof(double), typeof(Demo3), new PropertyMetadata(0.0, IntensityChanged));   private static void IntensityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var i = (byte)(double)e.NewValue; jQuery.Select("span").Css("color", string.Format("#{0:X2}{0:X2}{0:X2}", i)); }   An animation has to be created. This code defines a Storyboard with one keyframe that uses a bounce ease as an easing function. The animation is set to target the Intensity dependency property defined earlier.   private Storyboard CreateAnimation(double value) { Storyboard storyboard = new Storyboard(); var da = new DoubleAnimationUsingKeyFrames(); var d = new EasingDoubleKeyFrame { EasingFunction = new BounceEase(), KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1.0)), Value = value }; da.KeyFrames.Add(d); Storyboard.SetTarget(da, this); Storyboard.SetTargetProperty(da, new PropertyPath(Demo3.IntensityProperty)); storyboard.Children.Add(da); return storyboard; }   Initially the Intensity is set to 128 which results in a gray color. When one of the buttons is pressed, a new animation is created an played. One to animate to black, and one to animate to white.   public Demo3() { InitializeComponent(); Intensity = 128; }   private void button2_Click(object sender, RoutedEventArgs e) { CreateAnimation(255).Begin(); }   private void button3_Click(object sender, RoutedEventArgs e) { CreateAnimation(0).Begin(); }   Conclusion As you can see jLight can make the life of a Silverlight developer a lot easier when accessing the DOM. Almost all jQuery functions that are defined in jLight use the same constructions as described above. I’ve tried to stay as close as possible to the real jQuery. Having JavaScript perform callbacks to Silverlight using jLight will be described in more detail in a future tutorial about AJAX or eventing.

    Read the article

  • SharePoint logging to a list

    - by Norgean
    I recently worked in an environment with several servers. Locating the correct SharePoint log file for error messages, or development trace calls, is cumbersome. And once the solution hit the cloud, it got even worse, as we had no access to the log files at all. Obviously we are not the only ones with this problem, and the current trend seems to be to log to a list. This had become an off-hour project, so rather than do the sensible thing and find a ready-made solution, I decided to do it the hard way. So! Fire up Visual Studio, create yet another empty SharePoint solution, and start to think of some requirements. Easy on/offI want to be able to turn list-logging on and off.Easy loggingFor me, this means being able to use string.Format.Easy filteringLet's have the possibility to add some filtering columns; category and severity, where severity can be "verbose", "warning" or "error". Easy on/off Well, that's easy. Create a new web feature. Add an event receiver, and create the list on activation of the feature. Tear the list down on de-activation. I chose not to create a new content type; I did not feel that it would give me anything extra. I based the list on the generic list - I think a better choice would have been the announcement type. Approximately: public void CreateLog(SPWeb web)         {             var list = web.Lists.TryGetList(LogListName);             if (list == null)             {                 var listGuid = web.Lists.Add(LogListName, "Logging for the masses", SPListTemplateType.GenericList);                 list = web.Lists[listGuid];                 list.Title = LogListTitle;                 list.Update();                 list.Fields.Add(Category, SPFieldType.Text, false);                 var stringColl = new StringCollection();                 stringColl.AddRange(new[]{Error, Information, Verbose});                 list.Fields.Add(Severity, SPFieldType.Choice, true, false, stringColl);                 ModifyDefaultView(list);             }         }Should be self explanatory, but: only create the list if it does not already exist (d'oh). Best practice: create it with a Url-friendly name, and, if necessary, give it a better title. ...because otherwise you'll have to look for a list with a name like "Simple_x0020_Log". I've added a couple of fields; a field for category, and a 'severity'. Both to make it easier to find relevant log messages. Notice that I don't have to call list.Update() after adding the fields - this would cause a nasty error (something along the lines of "List locked by another user"). The function for deleting the log is exactly as onerous as you'd expect:         public void DeleteLog(SPWeb web)         {             var list = web.Lists.TryGetList(LogListTitle);             if (list != null)             {                 list.Delete();             }         } So! "All" that remains is to log. Also known as adding items to a list. Lots of different methods with different signatures end up calling the same function. For example, LogVerbose(web, message) calls LogVerbose(web, null, message) which again calls another method which calls: private static void Log(SPWeb web, string category, string severity, string textformat, params object[] texts)         {             if (web != null)             {                 var list = web.Lists.TryGetList(LogListTitle);                 if (list != null)                 {                     var item = list.AddItem(); // NOTE! NOT list.Items.Add… just don't, mkay?                     var text = string.Format(textformat, texts);                     if (text.Length > 255) // because the title field only holds so many chars. Sigh.                         text = text.Substring(0, 254);                     item[SPBuiltInFieldId.Title] = text;                     item[Degree] = severity;                     item[Category] = category;                     item.Update();                 }             } // omitted: Also log to SharePoint log.         } By adding a params parameter I can call it as if I was doing a Console.WriteLine: LogVerbose(web, "demo", "{0} {1}{2}", "hello", "world", '!'); Ok, that was a silly example, a better one might be: LogError(web, LogCategory, "Exception caught when updating {0}. exception: {1}", listItem.Title, ex); For performance reasons I use list.AddItem rather than list.Items.Add. For completeness' sake, let us include the "ModifyDefaultView" function that I deliberately skipped earlier.         private void ModifyDefaultView(SPList list)         {             // Add fields to default view             var defaultView = list.DefaultView;             var exists = defaultView.ViewFields.Cast<string>().Any(field => String.CompareOrdinal(field, Severity) == 0);               if (!exists)             {                 var field = list.Fields.GetFieldByInternalName(Severity);                 if (field != null)                     defaultView.ViewFields.Add(field);                 field = list.Fields.GetFieldByInternalName(Category);                 if (field != null)                     defaultView.ViewFields.Add(field);                 defaultView.Update();                   var sortDoc = new XmlDocument();                 sortDoc.LoadXml(string.Format("<Query>{0}</Query>", defaultView.Query));                 var orderBy = (XmlElement) sortDoc.SelectSingleNode("//OrderBy");                 if (orderBy != null && sortDoc.DocumentElement != null)                     sortDoc.DocumentElement.RemoveChild(orderBy);                 orderBy = sortDoc.CreateElement("OrderBy");                 sortDoc.DocumentElement.AppendChild(orderBy);                 field = list.Fields[SPBuiltInFieldId.Modified];                 var fieldRef = sortDoc.CreateElement("FieldRef");                 fieldRef.SetAttribute("Name", field.InternalName);                 fieldRef.SetAttribute("Ascending", "FALSE");                 orderBy.AppendChild(fieldRef);                   fieldRef = sortDoc.CreateElement("FieldRef");                 field = list.Fields[SPBuiltInFieldId.ID];                 fieldRef.SetAttribute("Name", field.InternalName);                 fieldRef.SetAttribute("Ascending", "FALSE");                 orderBy.AppendChild(fieldRef);                 defaultView.Query = sortDoc.DocumentElement.InnerXml;                 //defaultView.Query = "<OrderBy><FieldRef Name='Modified' Ascending='FALSE' /><FieldRef Name='ID' Ascending='FALSE' /></OrderBy>";                 defaultView.Update();             }         } First two lines are easy - see if the default view includes the "Severity" column. If it does - quit; our job here is done.Adding "severity" and "Category" to the view is not exactly rocket science. But then? Then we build the sort order query. Through XML. The lines are numerous, but boring. All to achieve the CAML query which is commented out. The major benefit of using the dom to build XML, is that you may get compile time errors for spelling mistakes. I say 'may', because although the compiler will not let you forget to close a tag, it will cheerfully let you spell "Name" as "Naem". Whichever you prefer, at the end of the day the view will sort by modified date and ID, both descending. I added the ID as there may be several items with the same time stamp. So! Simple logging to a list, with sensible a view, and with normal functionality for creating your own filterings. I should probably have added some more views in code, ready filtered for "only errors", "errors and warnings" etc. And it would be nice to block verbose logging completely, but I'm not happy with the alternatives. (yetanotherfeature or an admin page seem like overkill - perhaps just removing it as one of the choices, and not log if it isn't there?) Before you comment - yes, try-catches have been removed for clarity. There is nothing worse than having a logging function that breaks your site!

    Read the article

  • ASP.NET Wizard control with Dynamic UserControls

    - by wjat777
    Hello everyone I'm trying to use the Wizard control as follows: 1 - In the first step (first screen) has a cheklistbox with several options 2 - For each option selected, will be created an extra step 3 - In some steps may be set up intermediate stages Me problem is that each step is a usercontrol. So if the first step I select option1 and option3, I should create two more steps with usercontrol1 and UserControl3 .... Someone already did something similar? I will try explain better the problem. I'll paste here, but I put a copy of the project in skydrive: http://cid-3d949f1661d00819.skydrive.live.com/self.aspx/C%5E3/WizardControl2.7z It is a very basic example of what I'm trying to do. The project has page.ASPX 1 and 3 usercontrol.ASCX (UC1, UC2 and UC3) Default.ASPX: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" % Option1 Option2 Option3 Code Behind: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication2 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Page_PreInit(object sender, EventArgs e) { LoadSteps(); } private void LoadSteps() { int count = Wizard1.WizardSteps.Count; for (int i = count - 1; i > 0; i--) { WizardStepBase step = Wizard1.WizardSteps[i]; if (step.StepType != WizardStepType.Start) Wizard1.WizardSteps.Remove(step); } string Activities=""; foreach (ListItem item in CheckBoxList1.Items) { if (item.Selected) { WizardStep step = new WizardStep {ID = "step_" + item.Value, Title = "step_" + item.Value}; UserControl uc=null; switch (item.Value) { case "1": uc=(UserControl)LoadControl("~/UC1.ascx"); break; case "2": uc=(UserControl)LoadControl("~/UC2.ascx"); break; case "3": uc=(UserControl)LoadControl("~/UC3.ascx"); break; } step.Controls.Add(uc); Wizard1.WizardSteps.Add(step); } } } protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e) { LoadSteps(); } } } Control UC1.ASCX to UC3.ASCX has the same code (as an example) usercontrol.ascx: <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UC1.ascx.cs" Inherits="WebApplication2.UC1" % AutoPostBack="True" AutoPostBack="True" Code Behind: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication2 { public partial class UC1 : System.Web.UI.UserControl { protected void Page_Init(object sender, EventArgs e) { List list1 = new List { "Alice", "Bob", "Chris" }; List list2 = new List { "UN", "DEUX", "TROIS" }; DropDownList1.DataSource = list1; DropDownList2.DataSource = list2; DropDownList1.DataBind(); DropDownList2.DataBind(); } protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { Label1.Text = DropDownList1.SelectedValue; } protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { Label2.Text = DropDownList2.SelectedValue; } } } You can see that the controls UserControls trigger events (they cause postbacks) The behavior of this project is a little different than I described in the first thread, but the problem is the same. After the second time "next" button, you will get an error. Thanks in advance William

    Read the article

  • LinkButtons Created Dynamically in a Repeater Don't Fire ItemCommand Event

    - by 5arx
    Hi. I've got a repeater that's used to display the output of a dynamic report that takes criteria from webcontrols on the page. Within the repeater's ItemDataBound method I'm adding controls (Linkbuttons for sorting by column values) dynamically to the header of the repeater based on values selected in a checkbox list and at this point setting the CommandArgument and CommandName properties of the linkbuttons. The issue is that when the linkbuttons are clicked they don't fire the ItemCommand event although they are clearly being correctly created and added to the header (there is some additional code to set the cssClass, text etc. and this works as expected.) The first column header in the repeater is set in the markup and the itemcommand event fires correctly on this one only. When the other column headers are clicked the repeater rebinds as programmed, but the columns are not dynamically re-generated. I would really appreciate somebody explaining what I'm doing wrong - afaik I'm following the approved way of doing this :-( Simplified code follows: Nightmare.ascx <asp:repeater runat="server" id="rptReport" OnItemDataBound="rptResults_ItemDataBound" OnItemCommand="rptResults_ItemCommand" EnableViewState="true"> <headertemplate> <table> <tr runat="Server" id="TRDynamicHeader"> <th> <!-- This one works --> <asp:Linkbutton runat="server" CommandName="sort" commandArgument='<%# Eval("Name")%?' /> </th> <!-- additional header cells get added dynamically here --> </tr> </headertemplate> <itemTemplate> <td><%# Eval("Name")</td> ... </itemTemplate> </asp:repeater> Nightmare.ascx.cs protected void PageLoad(object sender, eventArgs e){ if (! isPostback){ setupGui();//just binds dropdowns etc. to datasources } } protected void btnRunReport_Click(...){ List<ReportLines> lstRep = GetReportLines(); rptReport.DataSource = lstRep; repReport.DataBind(); } protected void rptReport_ItemDataBound (...){ if (e.Item.ItemType == ListItemType.Header) { foreach (ListItem li in chbxListBusFuncs.Items) { if (li.Selected) { th = new HtmlTableCell(); lb = new LinkButton(); lb.CssClass = "SortColHeader"; lb.CommandArgument = li.Text.Replace(" ", ""); lb.CommandName = "sort"; lb.Text = li.Text; th.Controls.Add(lb); ((HtmlTableRow)e.Item.FindControl("TRDynamicHeader")).Cells.Add(th); } } } if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { //Row level customisations, totals calculations etc. } } <!-- this only gets called when the 'hardcoded' linkbutton in the markup is clicked. protected void rptReport_ItemCommand(object sender, Eventargs e){ lblDebug.Text = string.Format("Well? What's Happening? -> {0}:{1}", e.CommandName, e.CommandArgument.ToString()); } (The only thing that can call the runreport routine is a single button on the page, not shown in the code snippet above.)

    Read the article

  • Problem while inserting data from GUI layer to database

    - by Rahul
    Hi all, I am facing problem while i am inserting new record from GUI part to database table. I have created database table Patient with id, name, age etc....id is identity primary key. My problem is while i am inserting duplicate name in table the control should go to else part, and display the message like...This name is already exits, pls try with another name... but in my coding not getting..... Here is all the code...pls somebody point me out whats wrong or how do this??? GUILayer: protected void BtnSubmit_Click(object sender, EventArgs e) { if (!Page.IsValid) return; int intResult = 0; string name = TxtName.Text.Trim(); int age = Convert.ToInt32(TxtAge.Text); string gender; if (RadioButtonMale.Checked) { gender = RadioButtonMale.Text; } else { gender = RadioButtonFemale.Text; } string city = DropDownListCity.SelectedItem.Value; string typeofdisease = ""; foreach (ListItem li in CheckBoxListDisease.Items) { if (li.Selected) { typeofdisease += li.Value; } } typeofdisease = typeofdisease.TrimEnd(); PatientBAL PB = new PatientBAL(); PatientProperty obj = new PatientProperty(); obj.Name = name; obj.Age = age; obj.Gender = gender; obj.City = city; obj.TypeOFDisease = typeofdisease; try { intResult = PB.ADDPatient(obj); if (intResult > 0) { lblMessage.Text = "New record inserted successfully."; TxtName.Text = string.Empty; TxtAge.Text = string.Empty; RadioButtonMale.Enabled = false; RadioButtonFemale.Enabled = false; DropDownListCity.SelectedIndex = 0; CheckBoxListDisease.SelectedIndex = 0; } else { lblMessage.Text = "Name [<b>" + TxtName.Text + "</b>] alredy exists, try another name"; } } catch (Exception ex) { lblMessage.Text = ex.Message.ToString(); } finally { obj = null; PB = null; } } BAL layer: public class PatientBAL { public int ADDPatient(PatientProperty obj) { PatientDAL pdl = new PatientDAL(); try { return pdl.InsertData(obj); } catch { throw; } finally { pdl=null; } } } DAL layer: public class PatientDAL { public string ConString = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString; public int InsertData(PatientProperty obj) { SqlConnection con = new SqlConnection(ConString); con.Open(); SqlCommand com = new SqlCommand("LoadData",con); com.CommandType = CommandType.StoredProcedure; try { com.Parameters.AddWithValue("@Name", obj.Name); com.Parameters.AddWithValue("@Age",obj.Age); com.Parameters.AddWithValue("@Gender",obj.Gender); com.Parameters.AddWithValue("@City", obj.City); com.Parameters.AddWithValue("@TypeOfDisease", obj.TypeOFDisease); return com.ExecuteNonQuery(); } catch { throw; } finally { com.Dispose(); con.Close(); } } } Property Class: public class PatientProperty { private string name; private int age; private string gender; private string city; private string typedisease; public string Name { get { return name; } set { name = value; } } public int Age { get { return age; } set { age = value; } } public string Gender { get { return gender; } set { gender = value; } } public string City { get { return city; } set { city = value; } } public string TypeOFDisease { get { return typedisease; } set { typedisease = value; } } } This is my stored Procedure: CREATE PROCEDURE LoadData ( @Name varchar(50), @Age int, @Gender char(10), @City char(10), @TypeofDisease varchar(50) ) as insert into Patient(Name, Age, Gender, City, TypeOfDisease)values(@Name,@Age, @Gender, @City, @TypeofDisease) GO

    Read the article

  • JSON Paring - How to show second Level ListView

    - by Sophie
    I am parsing JSON data into ListView, and successfully parsed first level of JSON in MainActivity.java, where i am showing list of Main Locations, like: Inner Locations Outer Locations Now i want whenever i do tap on Inner Locations then in SecondActivity it should show Delhi and NCR in a List, same goes for Outer Locations as well, in this case whenever user do tap need to show USA JSON look like: { "all": [ { "title": "Inner Locations", "maps": [ { "title": "Delhi", "markers": [ { "name": "Connaught Place", "latitude": 28.632777800000000000, "longitude": 77.219722199999980000 }, { "name": "Lajpat Nagar", "latitude": 28.565617900000000000, "longitude": 77.243389100000060000 } ] }, { "title": "NCR", "markers": [ { "name": "Gurgaon", "latitude": 28.440658300000000000, "longitude": 76.987347699999990000 }, { "name": "Noida", "latitude": 28.570000000000000000, "longitude": 77.319999999999940000 } ] } ] }, { "title": "Outer Locations", "maps": [ { "title": "United States", "markers": [ { "name": "Virgin Islands", "latitude": 18.335765000000000000, "longitude": -64.896335000000020000 }, { "name": "Vegas", "latitude": 36.114646000000000000, "longitude": -115.172816000000010000 } ] } ] } ] } Note: But whenever i do tap on any of the ListItem in first activity, not getting any list in SecondActivity, why ? MainActivity.java:- @Override protected Void doInBackground(Void... params) { // Create an array arraylist = new ArrayList<HashMap<String, String>>(); // Retrieve JSON Objects from the given URL address jsonobject = JSONfunctions .getJSONfromURL("http://10.0.2.2/locations.json"); try { // Locate the array name in JSON jsonarray = jsonobject.getJSONArray("all"); for (int i = 0; i < jsonarray.length(); i++) { HashMap<String, String> map = new HashMap<String, String>(); jsonobject = jsonarray.getJSONObject(i); // Retrieve JSON Objects map.put("title", jsonobject.getString("title")); arraylist.add(map); } } catch (JSONException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void args) { // Locate the listview in listview_main.xml listview = (ListView) findViewById(R.id.listview); // Pass the results into ListViewAdapter.java adapter = new ListViewAdapter(MainActivity.this, arraylist); // Set the adapter to the ListView listview.setAdapter(adapter); // Close the progressdialog mProgressDialog.dismiss(); listview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(MainActivity.this, String.valueOf(position), Toast.LENGTH_LONG).show(); // TODO Auto-generated method stub Intent sendtosecond = new Intent(MainActivity.this, SecondActivity.class); // Pass all data rank sendtosecond.putExtra("title", arraylist.get(position).get(MainActivity.TITLE)); Log.d("Tapped Item::", arraylist.get(position).get(MainActivity.TITLE)); startActivity(sendtosecond); } }); } } } SecondActivity.java: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get the view from listview_main.xml setContentView(R.layout.listview_main); Intent in = getIntent(); strReceived = in.getStringExtra("title"); Log.d("Received Data::", strReceived); // Execute DownloadJSON AsyncTask new DownloadJSON().execute(); } // DownloadJSON AsyncTask private class DownloadJSON extends AsyncTask<Void, Void, Void> { @Override protected void onPreExecute() { super.onPreExecute(); } @Override protected Void doInBackground(Void... params) { // Create an array arraylist = new ArrayList<HashMap<String, String>>(); // Retrieve JSON Objects from the given URL address jsonobject = JSONfunctions .getJSONfromURL("http://10.0.2.2/locations.json"); try { // Locate the array name in JSON jsonarray = jsonobject.getJSONArray("maps"); for (int i = 0; i < jsonarray.length(); i++) { HashMap<String, String> map = new HashMap<String, String>(); jsonobject = jsonarray.getJSONObject(i); // Retrieve JSON Objects map.put("title", jsonobject.getString("title")); arraylist.add(map); } } catch (JSONException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return null; }

    Read the article

  • Selected Index Changed event not firing both Autopostback property

    - by TechGuy
    In my Dropdownlist Selected index change event not firing.Here i use auto post back true & View state also true.But Selected Index Changed Event not firing My Code <%@ Page Language="C#" AutoEventWireup="true" CodeFile="AdminEagleViewLogin.aspx.cs" Inherits="AdminEagleViewLogin" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <style> body{padding-top:20px;} </style> <title></title> </head> <body> <form id="form1" runat="server"> <div class="container"> <div class="row"> User : <asp:DropDownList ID="drpusr" runat="server" Visible="true" OnSelectedIndexChanged="drpusr_SelectedIndexChanged" AutoPostBack="true" EnableViewState="true" ></asp:DropDownList> Password: <asp:Label ID="lbluserpw" runat="server"></asp:Label> <div class="col-md-4 col-md-offset-4"> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">Please sign in</h3> </div> <div class="panel-body"> <form accept-charset="UTF-8" role="form"> <fieldset> <div class="form-group"> <asp:TextBox ID="txtusr" runat="server"></asp:TextBox> </div> <div class="form-group"> <asp:TextBox ID="txtpw" runat="server" TextMode="Password"></asp:TextBox> </div> <div class="checkbox"> <label> <input name="remember" type="checkbox" value="Remember Me"> Remember Me </label> </div> <asp:CheckBox ID="chkremember" runat="server" Visible="false" class="remchkbox" /> <asp:Button ID="submit" runat="server" class="btn btn-lg btn-success btn-block" Text="Submit" OnClick="submit_Click" /> </fieldset> </form> </div> </div> </div> </div> </div> </form> </body> </html> ServerSide User bind to Dropdown is working. public partial class AdminEagleViewLogin : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { BindUsers(); //lbluserpw.Text = Membership.Provider.GetPassword(drpusr.SelectedValue, String.Empty); } protected void submit_Click(object sender, EventArgs e) { if (Membership.ValidateUser(txtusr.Text, txtpw.Text)) { FormsAuthentication.SetAuthCookie(txtusr.Text, chkremember.Checked); string[] CurrentUserRole = Roles.GetRolesForUser(txtusr.Text); var admin = "Administrator"; var manager = "Manager"; var user = "User"; if (CurrentUserRole.Contains(admin)) { Response.Redirect("Administrator.aspx"); } else if (CurrentUserRole.Contains(manager)) { Response.Redirect("Manager.aspx"); } else { Response.Redirect("UserPage.aspx"); } } else { Response.Redirect("AdminEagleViewLogin.aspx"); } } protected void BindUsers() { DataAccess da = new DataAccess(); drpusr.DataSource = da.GetUsers(); drpusr.DataTextField = "UserName"; drpusr.DataValueField = "UserId"; drpusr.DataBind(); drpusr.Items.Insert(0, new ListItem("-- Select User --", "0")); drpusr.Items.RemoveAt(1); } protected void drpusr_SelectedIndexChanged(object sender, EventArgs e) { lbluserpw.Text = Membership.Provider.GetPassword(drpusr.SelectedValue, String.Empty); } }

    Read the article

  • CodePlex Daily Summary for Monday, April 05, 2010

    CodePlex Daily Summary for Monday, April 05, 2010New Projects.Net Data Form Wizard: A Basic .Net application that will connect to a SQL Server, allow you to select a database, then select from the user created tables, read the tabl...Agilisa Data.Controls: Agilisa DataControls provides ready to use Databound controls, encapsulating the data connection logic, caching, for ASP.NET Controls. Just drop th...algoritmia: A Python 3.1+ library of Data Structures and Algorithms. This library is being used to teach a course on Algorithms in my university. It contains ...Bag of Tricks: The original WPF Bag of tricks, now maintained by your friends at Pixel Lab.DIMIS: It is a simple asp.net system, just for practice!DotNetNuke® Postgres Data Provider: DNN PG Provider is a DotNetNuke® 4.9.2 Data Provider for PostgreSQL, an enterprise class open source database system. With DNN PG DataProvider y...Home Finance: This project develop to manage your home finance.House Repair Management System: House Repair Management SystemLaunchpadNET: LaunchpadNET is a C# library for interfacing your .NET program with the Novation Launchpad controller.Mapsui - UI for maps: Mapsui is a UI library for mapping applications. It is based on BruTile and SharpMap. It is designed to be fast and responsive.micronovo: micronovomicronovomicronovomicronovoNPlurk: The project goal is to provide a .NET implemented Plurk API wrapper. PowerExt: PowerExt is a Windows Explorer add-in written in C++. Primarily targeted at programmers, it adds an additional .NET tab to the File Properties dial...Python Multiple Dispatch: Multiple dispatch (AKA multimethods) for Python 3 via a metaclass and type annotations.SpugDisposeCheck - Visual Studio Addin for validating Sharepoint dispose objects: AddIn that wraps the SPDisposeCheck Tool from Microsoft and fully integrate it with Visual Studio.System.Tuples: System.Tuples is a small tuple library. It uses T4 to generate tuples, and is made to be compatible with .net 2.0, .net 3.0 and .net 3.5.WebStatistics Server for Windows Server: WebStatistics Server for Windows Server is a tool to create visitor and traffic statistics of a Windows Server running IIS Webserver. It includes a...whileActivity Test: This is a temporary project to test the whileActivity and the updateResourceActivity (Forefront Identity Manager 2010 rtm)XBMC NFO Exporter: XBMC Nfo Exporter is a simple utility that allows you to create reports based on your media XMBC NFO files.XML Flattener: A simple tool to flatten "pretty"-printed XML files into a single line for use in web service test situations, etc. xvanneste: Sources et exemples utilisés sur le site http://www.xvanneste.com et http://media.xvanneste.comzhengym: 这是我个人的测试项目New Releases.Net Data Form Wizard: Alpha: I am only providing the logical code at this point. I will release a completed project once it has basic functionality, at the moment it only gener....Net Data Form Wizard: Alpha Code: This is only the basic VB code to create a form from the database information.Alter gear SQL index Management: Setup 1.1.1: Changes : Added ability to save / delete connection stringsExcelDna: ExcelDna Version 0.24: This versions adds packing support for .config files, and fixes a bug where temp files were not cleaned up.Hash Calculator: HashCalculator 1.1: Added drag-and-drop support Fixed some bugsHeadCounter: HeadCounter 1.2.4 'Vaelastrasz': Added a basic bbcode option for forum posting to sites that do not support full bbcode implementations (e.g. Guild Portal)Home Access Plus+: v3.2.5.0: v3.2.5.0 Release Change Log: Added the booking system File Changes: ~/app_data/* ~/bin/CHS.dll ~/bin/CHS.pdb ~/bin/CHS Extranet.dll ~/bin/...Home Access Plus+: v3.2.5.1: v3.2.5.1 Release Change Log: Fixed access to the booking system for non domain admin File Changes: ~/bin/CHS Extranet.dll ~/bin/CHS Extranet.pdb...Howard van Rooijen's Code Samples: Getting Started with MongoDB and NoRM: Code to accompany the blog post A .NET Developer Guide to: MongoDB and NoRM This download contains the a solution with the following structure: G...iExporter - iTunes playlist exporting: iExporter gui v2.5.1.0 - console v1.2.1.0: Paypal donate! Fixed small bug for iExporter Gui When pressing the Select button more then once, the Deselect button would not disable the Export...IST435: Lab 2 Demo Solution: Lab 2 Demo Solution - OverviewThis is a demo solution for Lab 2 which meets the basic requirements of the lab. Note that this solution has the foll...JSINQ - LINQ to Objects for JavaScript: JSINQ 1.0.0.1: Minor bugfixes with the Enumerable and Dictionary implementations.Mavention: Mavention Instant Page Create: Mavention Instant Page Create allows you to create new Publishing Pages with a single mouse click. Screenshots and more information available @ htt...Microsoft Dynamics CRM 4.0 Marketing List Member Importer: Nocelab ExcelAddin - Release 2.2: Version: 2.2 Release Note: - Added tab in the task panel - Added test button to check MSCRM connection How to install: - Uninstall previous ve...Multiplayer Quiz: Release 1_6_903_0b: Latest beta release - please leave any bugs etc in comments.MVVM Light Toolkit: MVVM Light Toolkit V3 SP1: This release can be installed on top of V3, and adds the following features: Project and Item templates for Visual Studio 10 Express (phone editio...NPlurk: First release: This is first release of NPlurk and it's almost completely workable. Enjoy!Performance Analysis of Logs (PAL) Tool: PAL v2.0 Alpha 5: Export to Perfmon Log Template or Data Collector Set Added: Added the feature to export perfmon log templates (*.htm) for WinXP/2003 computers or D...Python Multiple Dispatch: v0.1: Initial release. I believe it is working fine.ReRemind: V7: - Added new notification: "Unread MMS" <- Default is enabled, so be sure to go into Config if you don't want this. - Config now supports sound and ...SharePhone: SharePhone v.1.0.2: Added support for retrieving user profiles and saving back to SharePoint Use clientContext.GetUserProfile(..) or clientContext.UpdateUserProfile(..)Shinkansen: compress, crunch, combine, and cache JavaScript and CSS: Shinkansen 1.0.0.033010: Added support for ASP.NET MVC. Download contains binaries only.SpugDisposeCheck - Visual Studio Addin for validating Sharepoint dispose objects: SpugDisposeCheck Beta Release [Stable]: SpugDisposeCheck - Visual Studio Addin for validating Sharepoint dispose objects You can download the Microsoft SPDisposeCheck Tool from here:http...Starter Kit Mytrip.Mvc.Entity: Mytrip.Mvc.Entity 1.0 RC2: EF Membership XML Membership UserManager FileManager Localization Captcha ClientValidation Theme CrossBrowser VS 2010 RC MVC 2 R...System.Tuples: System.Tuples for .net 2.0: The System.Tuples release for .net 3.0System.Tuples: System.Tuples for .net 3.0: The System.Tuples release for .net 3.0 Extension methods have been removed to remain compatible with 3.0System.Tuples: System.Tuples for .net 3.5: The System.Tuples release for .net 3.5 Contains full functionality of the library.WatchersNET.TagCloud: WatchersNET.TagCloud 01.03.00: Whats New Html (non Flash) TagCloud can be skinned 11 Skins added for Html Cloud Skin Orange Skin Purple Import/Export of Custom Tags Sett...whileActivity Test: Activity1.zip: ActivityLibrary1.zip contains the source code to do a testWindows Phone 7 Panorama control: panorama control v0.5: Control source code for v0.5. This is the first drop. Doens't include sample project.Windows Phone 7 Panorama control: panorama control v0.5 + samples: Control source code and sample project. This drop includes 2 samples projects : - PhoneApp - Windows Phone sample - SilverlightApp - Silverlight...XML Flattener: XML Flattener: A simple WinForms app--paste in your XML, hit Flatten, and copy the result.xvanneste: RestFul SharePoint: ListItem.xslt ListItems.xslt Lists.xslt ListItemSPChat.xslt RestFull.htm SPChat.htmZinc Launcher: Zinc Launcher 1.0.1.0: Zinc Launcher requires that Zinc be properly installed. It should work under Vista Media Center and 7 Media Center, although Vista is untested. Zin...Most Popular ProjectsRawrWBFS ManagerMicrosoft SQL Server Product Samples: DatabaseASP.NET Ajax LibrarySilverlight ToolkitAJAX Control ToolkitWindows Presentation Foundation (WPF)ASP.NETMicrosoft SQL Server Community & SamplesDotNetNuke® Community EditionMost Active ProjectsGraffiti CMSnopCommerce. Open Source online shop e-commerce solution.RawrFacebook Developer ToolkitjQuery Library for SharePoint Web ServicesBlogEngine.NETFarseer Physics EngineNcqrs Framework - A CQRS framework for .NETpatterns & practices – Enterprise LibraryN2 CMS

    Read the article

  • ASP.NET TextBox TextChanged event not firing in custom EditorPart

    - by Ben Collins
    This is a classic sort of question, I suppose, but it seems that most people are interested in having the textbox cause a postback. I'm not. I just want the event to fire when a postback occurs. I have created a webpart with a custom editorpart. The editorpart renders with a textbox and a button. Clicking the button causes a dialog to open. When the dialog is closed, it sets the value of the textbox via javascript and then does __doPostBack using the ClientID of the editorpart. The postback happens, but the TextChanged event never fires, and I'm not sure if it's a problem with the way __doPostBack is invoked, or if it's because of the way I'm setting up the event handler, or something else. Here's what I think is the relevant portion of the code from the editorpart: protected override void CreateChildControls() { _txtListUrl = new TextBox(); _txtListUrl.ID = "targetSPList"; _txtListUrl.Style.Add(HtmlTextWriterStyle.Width, "60%"); _txtListUrl.ToolTip = "Select List"; _txtListUrl.CssClass = "ms-input"; _txtListUrl.Attributes.Add("readOnly", "true"); _txtListUrl.Attributes.Add("onChange", "__doPostBack('" + this.ClientID + "', '');"); _txtListUrl.Text = this.ListString; _btnListPicker = new HtmlInputButton(); _btnListPicker.Style.Add(HtmlTextWriterStyle.Width, "60%"); _btnListPicker.Attributes.Add("Title", "Select List"); _btnListPicker.ID = "browseListsSmtButton"; _btnListPicker.Attributes.Add("onClick", "mso_launchListSmtPicker()"); _btnListPicker.Value = "Select List"; this.AddConfigurationOption("News List", "Choose the list that serves as the data source.", new Control[] { _txtListUrl, _btnListPicker }); if (this.ShowViewSelection) { _txtListUrl.TextChanged += new EventHandler(_txtListUrl_TextChanged); _ddlViews = new DropDownList(); _ddlViews.ID = "_ddlViews"; this.AddConfigurationOption("View", _ddlViews); } } protected override void OnPreRender(EventArgs e) { ScriptLink.Register(this.Page, "PickerTreeDialog.js", true); string lastSelectedListId = string.Empty; if (!this.WebId.Equals(Guid.Empty) && !this.ListId.Equals(Guid.Empty)) { lastSelectedListId = SPHttpUtility.EcmaScriptStringLiteralEncode( string.Format("SPList:{0}?SPWeb:{1}:", this.ListId.ToString(), this.WebId.ToString())); } string script = "\r\n var lastSelectedListSmtPickerId = '" + lastSelectedListId + "';" + "\r\n function mso_launchListSmtPicker(){" + "\r\n if (!document.getElementById) return;" + "\r\n" + "\r\n var listTextBox = document.getElementById('" + SPHttpUtility.EcmaScriptStringLiteralEncode(_txtListUrl.ClientID) + "');" + "\r\n if (listTextBox == null) return;" + "\r\n" + "\r\n var serverUrl = '" + SPHttpUtility.EcmaScriptStringLiteralEncode(SPContext.Current.Web.ServerRelativeUrl) + "';" + "\r\n" + "\r\n var callback = function(results) {" + "\r\n if (results == null || results[1] == null || results[2] == null) return;" + "\r\n" + "\r\n lastSelectedListSmtPickerId = results[0];" + "\r\n var listUrl = '';" + "\r\n if (listUrl.substring(listUrl.length-1) != '/') listUrl = listUrl + '/';" + "\r\n if (results[1].charAt(0) == '/') results[1] = results[1].substring(1);" + "\r\n listUrl = listUrl + results[1];" + "\r\n if (listUrl.substring(listUrl.length-1) != '/') listUrl = listUrl + '/';" + "\r\n if (results[2].charAt(0) == '/') results[2] = results[2].substring(1);" + "\r\n listUrl = listUrl + results[2];" + "\r\n listTextBox.value = listUrl;" + "\r\n __doPostBack('" + this.ClientID + "','');" + "\r\n }" + "\r\n LaunchPickerTreeDialog('CbqPickerSelectListTitle','CbqPickerSelectListText','websLists','', serverUrl, lastSelectedListSmtPickerId,'','','/_layouts/images/smt_icon.gif','', callback);" + "\r\n }"; this.Page.ClientScript.RegisterClientScriptBlock(typeof(ListPickerEditorPart), "mso_launchListSmtPicker", script, true); if ((!string.IsNullOrEmpty(_txtListUrl.Text) && _ddlViews.Items.Count == 0) || _listSelectionChanged) { _ddlViews.Items.Clear(); if (!string.IsNullOrEmpty(_txtListUrl.Text)) { using (SPWeb web = SPContext.Current.Site.OpenWeb(this.WebId)) { foreach (SPView view in web.Lists[this.ListId].Views) { _ddlViews.Items.Add(new ListItem(view.Title, view.ID.ToString())); } } _ddlViews.Enabled = _ddlViews.Items.Count > 0; } else { _ddlViews.Enabled = false; } } base.OnPreRender(e); } void _txtListUrl_TextChanged(object sender, EventArgs e) { this.SetPropertiesFromChosenListString(_txtListUrl.Text); _listSelectionChanged = true; } Any ideas? Update: I forgot to mention these methods, which are called above: protected virtual void AddConfigurationOption(string title, Control inputControl) { this.AddConfigurationOption(title, null, inputControl); } protected virtual void AddConfigurationOption(string title, string description, Control inputControl) { this.AddConfigurationOption(title, description, new List<Control>(new Control[] { inputControl })); } protected virtual void AddConfigurationOption(string title, string description, IEnumerable<Control> inputControls) { HtmlGenericControl divSectionHead = new HtmlGenericControl("div"); divSectionHead.Attributes.Add("class", "UserSectionHead"); this.Controls.Add(divSectionHead); HtmlGenericControl labTitle = new HtmlGenericControl("label"); labTitle.InnerHtml = HttpUtility.HtmlEncode(title); divSectionHead.Controls.Add(labTitle); HtmlGenericControl divUserSectionBody = new HtmlGenericControl("div"); divUserSectionBody.Attributes.Add("class", "UserSectionBody"); this.Controls.Add(divUserSectionBody); HtmlGenericControl divUserControlGroup = new HtmlGenericControl("div"); divUserControlGroup.Attributes.Add("class", "UserControlGroup"); divUserSectionBody.Controls.Add(divUserControlGroup); if (!string.IsNullOrEmpty(description)) { HtmlGenericControl spnDescription = new HtmlGenericControl("div"); spnDescription.InnerHtml = HttpUtility.HtmlEncode(description); divUserControlGroup.Controls.Add(spnDescription); } foreach (Control inputControl in inputControls) { divUserControlGroup.Controls.Add(inputControl); } this.Controls.Add(divUserControlGroup); HtmlGenericControl divUserDottedLine = new HtmlGenericControl("div"); divUserDottedLine.Attributes.Add("class", "UserDottedLine"); divUserDottedLine.Style.Add(HtmlTextWriterStyle.Width, "100%"); this.Controls.Add(divUserDottedLine); }

    Read the article

  • getting database connectivity issue from only one part of my ASP.net project?

    - by Greg
    Hi, Something weird has started happening to my project with Dynamic Data. Suddenly I am now getting connection errors when going to the DD navigation pages, but things work fine on the default DD main page, and also other MVC pages I've added in myself work fine to the database. Any ideas? So in summary if I go to the following web pages: custom URL for my custom controller - this works fine, including getting database data main DD page from root URL - this works fine click on a link to a table maintenance page from the main DD page - GET DATABASE CONNECTIVITY ERROR Some items: * I'm using SQL Server Express 2008 * Doesn't seem to be any debug/error info in VS2010 at all I can see * Web config entry: <add name="Model1Container" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=GREG\SQLEXPRESS_2008;Initial Catalog=greg_development;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/> Error: Server Error in '/' Application. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) Source Error: Line 39: DropDownList1.Items.Add(new ListItem("[Not Set]", NullValueString)); Line 40: } Line 41: PopulateListControl(DropDownList1); Line 42: // Set the initial value if there is one Line 43: string initialValue = DefaultValue; Source File: U:\My Dropbox\source\ToplogyLibrary\Topology_Web_Dynamic\DynamicData\Filters\ForeignKey.ascx.cs Line: 41 Stack Trace: [SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5009598 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234 System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity) +341 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +129 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +239 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +33 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126 System.Data.SqlClient.SqlConnection.Open() +125 System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +52 [EntityException: The underlying provider failed on Open.] System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +161 System.Data.EntityClient.EntityConnection.Open() +98 System.Data.Objects.ObjectContext.EnsureConnection() +81 System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +46 System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +44 System.Data.Objects.ObjectQuery`1.GetEnumeratorInternal() +36 System.Data.Objects.ObjectQuery.System.Collections.IEnumerable.GetEnumerator() +10 System.Web.DynamicData.Misc.FillListItemCollection(IMetaTable table, ListItemCollection listItemCollection) +50 System.Web.DynamicData.QueryableFilterUserControl.PopulateListControl(ListControl listControl) +85 Topology_Web_Dynamic.ForeignKeyFilter.Page_Init(Object sender, EventArgs e) in U:\My Dropbox\source\ToplogyLibrary\Topology_Web_Dynamic\DynamicData\Filters\ForeignKey.ascx.cs:41 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnInit(EventArgs e) +91 System.Web.UI.UserControl.OnInit(EventArgs e) +83 System.Web.UI.Control.InitRecursive(Control namingContainer) +140 System.Web.UI.Control.AddedControl(Control control, Int32 index) +197 System.Web.UI.ControlCollection.Add(Control child) +79 System.Web.DynamicData.DynamicFilter.EnsureInit(IQueryableDataSource dataSource) +200 System.Web.DynamicData.QueryableFilterRepeater.<Page_InitComplete>b__1(DynamicFilter f) +11 System.Collections.Generic.List`1.ForEach(Action`1 action) +145 System.Web.DynamicData.QueryableFilterRepeater.Page_InitComplete(Object sender, EventArgs e) +607 System.EventHandler.Invoke(Object sender, EventArgs e) +0 System.Web.UI.Page.OnInitComplete(EventArgs e) +8871862 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +604 Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

    Read the article

  • How to obtain listview information without refreshing the page?

    - by user1808098
    I am currently developing an Android Application for my Final Year Project. But to be honest I do not have any basic knowledges and everything started from scratch and referring to online tutorials a lot. Here is my question, I was trying to retrieve data from listview activity. There are two listview in my page using button. I was able to display the first listview but when it get data for the second listview, the data for first listview is disappeared because the page is refreshed, vice versa. What code should I modified to get both the data in the page? (Database not implemented yet) Please help, thanks a lot. Below are my codings. Codings for XML. <!-- Location --> <TextView android:id="@+id/TextViewLocation" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginBottom="10dip" android:text="Location Information" android:gravity="center" android:textSize="15dip" android:textColor="#025f7c"/> <!-- Condition Label --> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#372c24" android:text="Traffic Condition"/> <Button android:id="@+id/inputListView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginBottom="10dip" android:text="choose one..."/> <!-- Comment Label --> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#372c24" android:text="What's Happening?"/> <Button android:id="@+id/inputListView2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginBottom="10dip" android:text="choose one..."/> <!-- Suggestion Label --> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#372c24" android:text="Comments / Suggestion"/> <EditText android:layout_width="fill_parent" android:layout_height="80dp" android:layout_marginTop="5dip" android:layout_marginBottom="10dip" android:singleLine="true"/> <!-- Image button --> <Button android:id="@+id/btnImage" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:text="Upload Image"/> <!-- Report button --> <Button android:id="@+id/btnReportCheckin" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:text="Report"/> <!-- Link to Logout --> <TextView android:id="@+id/linkLogout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginBottom="40dip" android:text="Log Out" android:gravity="center" android:textSize="20dip" android:textColor="#025f7c"/> </LinearLayout> <!-- Check or Report Form Ends --> Codings for Activity Class public class CheckinActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set View to checkin.xml setContentView(R.layout.checkin); /* TextView LocationView = (TextView) findViewById(R.id.TextViewLocation); Intent h = getIntent(); // getting attached intent data String address = h.getStringExtra("address"); // displaying selected product name LocationView.setText(address); */ Button ListViewScreen = (Button) findViewById(R.id.inputListView); //Listening to Button ListViewScreen.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //Switching to ListView Screen Intent i = new Intent(getApplicationContext(), ListViewActivity.class); startActivity(i); } } ); Button SelectedView = (Button) findViewById(R.id.inputListView); Intent i = getIntent(); // getting attached intent data String product = i.getStringExtra("product"); // displaying selected product name SelectedView.setText(product); Button ListView2Screen = (Button) findViewById(R.id.inputListView2); //Listening to Button ListView2Screen.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //Switching to ListView Screen Intent j = new Intent(getApplicationContext(), ListView2Activity.class); startActivity(j); } } ); Button SelectedView2 = (Button) findViewById(R.id.inputListView2); Intent j = getIntent(); // getting attached intent data String product2 = j.getStringExtra("product2"); // displaying selected product name SelectedView2.setText(product2); TextView Logout = (TextView) findViewById(R.id.linkLogout); // Listening to Log out Logout.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { // Closing menu screen // Switching to Login Screen/closing register screen finish(); } }); } } Coding for listview class public class ListViewActivity extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // storing string resources into Array String[] traffic_condition = getResources().getStringArray(R.array.traffic_condition); // Binding resources Array to ListAdapter this.setListAdapter(new ArrayAdapter<String>(this, R.layout.listitem, R.id.listViewLayout, traffic_condition)); ListView lv = getListView(); // listening to single list item on click lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // selected item String product = ((TextView) view).getText().toString(); // Launching new Activity on selecting single List Item Intent i = new Intent(getApplicationContext(), CheckinActivity.class); // sending data to new activity i.putExtra("product", product); startActivity(i); } }); } } Hope I made myself clear, I can provide a screen shot of my apps if it is required, thanks!

    Read the article

  • JavaNullPointerException/Layout Error when working with lists and ListView on Android

    - by psyhclo
    Hey, I'm trying to implement a ListView on Android, which will print the data retrieved from the SQLite Database. So I want to retrieve a lot of columns from the table and add this to a list, so I will print this list as a ListView. For this I created a method that will select all the columns from the table in a separate class, and I will print the ListView in a ListActivity. I want to retrieve 6 columns of the table, which is represented by the ids 2, 4, 5, 6, 7, 9. But it shows a lot of errors: 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): FATAL EXCEPTION: main 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): java.lang.NullPointerException 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:355) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.AbsListView.obtainView(AbsListView.java:1418) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.ListView.makeAndAddView(ListView.java:1745) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.ListView.fillDown(ListView.java:670) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.ListView.fillFromTop(ListView.java:727) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.ListView.layoutChildren(ListView.java:1598) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.AbsListView.onLayout(AbsListView.java:1248) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.ViewRoot.performTraversals(ViewRoot.java:1140) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.os.Handler.dispatchMessage(Handler.java:99) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.os.Looper.loop(Looper.java:123) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.app.ActivityThread.main(ActivityThread.java:3647) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at java.lang.reflect.Method.invokeNative(Native Method) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at java.lang.reflect.Method.invoke(Method.java:507) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at dalvik.system.NativeStart.main(Native Method) Here is the code of the method that select the data. public List<String> selectAll() { List<String> list1 = new ArrayList<String>(); List<String> list2 = new ArrayList<String>(); List<String> list3 = new ArrayList<String>(); List<String> list4 = new ArrayList<String>(); List<String> list5 = new ArrayList<String>(); List<String> list6 = new ArrayList<String>(); Cursor cursor = this.db.query(TABLE_NAME, null, null, null, null, null, "duration desc"); if (cursor.moveToFirst()) { do { list1.add(cursor.getString(2)); list2.add(cursor.getString(4)); list3.add(cursor.getString(5)); list4.add(cursor.getString(6)); list5.add(cursor.getString(7)); list6.add(cursor.getString(9)); list1.addAll(list2); list1.addAll(list3); list1.addAll(list4); list1.addAll(list5); list1.addAll(list6); } while (cursor.moveToNext()); Log.i(TAG, "After cursor.moveToNext()"); } if (cursor != null && !cursor.isClosed()) { cursor.close(); } Log.i(TAG, "Before selectAll returnment"); return list1; } And here is the code of the ListActivity class: public class RatedCalls extends ListActivity { private static final String LOG_TAG = "RatedCallsActivity"; private CallDataHelper cdh; StringBuilder sb = new StringBuilder(); OpenHelper openHelper = new OpenHelper(RatedCalls.this); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.i(LOG_TAG, "calling from onCreate()"); cdh = new CallDataHelper(this); Log.i(LOG_TAG, "--->>> before calling the service"); startService(new Intent(this, RatedCallsService.class)); Log.i(LOG_TAG, "Service called."); Log.i(LOG_TAG, "--->>> after calling the service"); fillList(); } public void fillList() { List<String> ratedCalls = this.cdh.selectAll(); setListAdapter(new ArrayAdapter<String>(this, R.layout.listitem, ratedCalls)); ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // When clicked, show a toast with the TextView text Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show(); } }); } }

    Read the article

  • $(document).ready(function(){ executed every time on onclick event of Hyperlink?

    - by Photon Critical Fatal Error_
    In my code I'm creating a product list dynamically using PHP(see image) and the currosponding labels and image paths are stored into hidden fields(created dynamically using PHP) now on document.ready() method i set the first list item's imagepath to img's src and its remarks to label remarks using first hidden fields for remark and imagepath. and on listitem click i want to change it my function set these values to img and label rightly(checked using alerts) but when function ends it set the image src and remarks innertext to default that is set on document.ready() method now my question is can i prevent the document.ready() to be executed next time on javascript function call My View : As the images are reloaded so the page rendering is done again so the document.ready is called again and set these values again to default. Note : My page is not reloading any time only images and labels are being changed The listshown in image is just one group other group is also created dynamically . server side code in PHP <?php for($j=0;$j<count($productstr);$j++) { $valuerem = $productstr[$j]["pcode"]; $idrem = "rem".$j.$grp; $valueimg =$productstr[$j]["imgpath"]; $idimg = "img".$j.$grp; echo "<input type='hidden' value='$valuerem' id='$idrem' />" ; echo "<input type='hidden' value='$valueimg' id='$idimg' />" ; }?> <script> $(document).ready(function() { idrv < ? PHP echo $grp; ? > = 'rem0<?PHP echo $grp; ?>'; idmv < ? PHP echo $grp; ? > = 'img0<?PHP echo $grp; ?>'; $('#txt<?PHP echo $grp; ?>').text(document.getElementById(idrv < ? PHP echo $grp; ? ).value); alert($('#txt<?PHP echo $grp; ?>').text()); $('#img<?PHP echo $grp; ?>').attr('src', document.getElementById(idmv < ? PHP echo $grp; ? > ).value); alert($('#img<?PHP echo $grp; ?>').attr('src')); }); function Change(id) { idrv < ? PHP echo $grp; ? > = 'rem' + id; idmv < ? PHP echo $grp; ? > = 'img' + id; $('#txt<?PHP echo $grp; ?>').text(document.getElementById(idrv < ? PHP echo $grp; ? > ).value); alert($('#txt<?PHP echo $grp; ?>').text()); $('#img<?PHP echo $grp; ?>').attr('src', document.getElementById(idmv < ? PHP echo $grp; ? > ).value); alert($('#img<?PHP echo $grp; ?>').attr('src')); return true; }? </script> alerts are used just to test the values the code that are being generated at client browser <tr> <td width="220px" valign="top" align="left"> <input id="YN" type="hidden" value="true"> <input id="rem00" type="hidden" value="SPL FUNNEL 1"> <input id="img00" type="hidden" value="adminpanel/product_images/4f8e530154d74155.jpg"> <input id="rem10" type="hidden" value="SPL FUNNEL 2"> <input id="img10" type="hidden" value="adminpanel/product_images/4f8e53daf13e6156.jpg"> <input id="rem20" type="hidden" value="SPL FUNNEL 3"> <input id="img20" type="hidden" value="adminpanel/product_images/4f8e543100eaf157.jpg"> <input id="rem30" type="hidden" value="SPL FUNNEL 4"> <input id="img30" type="hidden" value="adminpanel/product_images/4f8e545a829e1158.jpg"> <script> $(document).ready(function() { idrv0 = 'rem00'; idmv0 = 'img00'; $('#txt0').text(document.getElementById(idrv0).value); alert($('#txt0').text()); $('#img0').attr('src', document.getElementById(idmv0).value); alert($('#img0').attr('src')); }); function Change(id) { $('#YN').val('false'); idrv0 = 'rem' + id; idmv0 = 'img' + id; $('#txt0').text(document.getElementById(idrv0).value); alert($('#txt0').text()); $('#img0').attr('src', document.getElementById(idmv0).value); alert($('#img0').attr('src')); return true; }? </script> <ul> <li> <a id="00" style="text-decoration: none; text-size: 1.1em; color: " onclick=" Change(this.id); alert($('#txt0').text()); alert($('#img0').attr('src'));"> SPL FUNNEL 1</a> </li> <li> <li> <li> </ul> </td> <td valign="bottom" align="left" colspan="2"> <td width="110px" valign="bottom" align="left" style="width: 180px"> </tr>

    Read the article

  • How to implement EntityDataSource Where IN entity sql clause

    - by TonyS
    I want to pass a number of values into a parameter of the EntityDataSource, e.g.: Where="it.ORDER_ID IN {@OrderIdList}" (this is a property on the EntityDataSource) <WhereParameters> <asp:ControlParameter Name="OrderIdList" Type="Int16" ControlID="OrderFilterControl" PropertyName="OrderIdList" /> </WhereParameters> This doesn't work as ORDER_ID is of type int32 and I need to pass in multiple values, e.g. {1,2,3} etc The next thing I tried was setting the Where clause in code-behind and this all works except I can't get data binding on DropDownLists to work. By this I mean no value is returned from the bound dropdownlists in the EntityDataSource Updating Event. My ideal solution would be to use a WhereParameter on the EntityDataSource but any help is appreciated. Thanks, Tony. A complete code example follows using the AdventureWorks db: Public Class EntityDataSourceWhereInClause Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load CustomersEntityDataSource.Where = WhereClause ''# reset after each postback as its lost otherwise End Sub Private Sub cmdFilterCustomers_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdFilterCustomers.Click Dim CustomerIdList As New Generic.List(Of Int32) For Each item As ListItem In CustomerIdCheckBoxList.Items If item.Selected Then CustomerIdList.Add(item.Value) End If Next Dim CustomerCsvList As String = String.Join(", ", CustomerIdList.Select(Function(o) o.ToString()).ToArray()) WhereClause = "it.CustomerID IN {" & CustomerCsvList & "}" CustomersEntityDataSource.Where = WhereClause FormView1.PageIndex = 0 End Sub ''# save between postbacks the custom Where IN clause Public Property WhereClause() As String Get Return ViewState("WhereClause") End Get Set(ByVal value As String) ViewState.Add("WhereClause", value) End Set End Property Private Sub CustomersEntityDataSource_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.EntityDataSourceChangingEventArgs) Handles CustomersEntityDataSource.Updating Dim c = CType(e.Entity, EntityFrameworkTest.Customer) If c.Title.Length = 0 Then Response.Write("Title is empty string, so will save like this!") End If End Sub End Class <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="EntityDataSourceWhereInClause.aspx.vb" Inherits="EntityFrameworkTest.EntityDataSourceWhereInClause" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <%''# filter control %> <div> <asp:EntityDataSource ID="CustomerIdListEntityDataSource" runat="server" ConnectionString="name=AdventureWorksLT2008Entities" DefaultContainerName="AdventureWorksLT2008Entities" EnableFlattening="False" EntitySetName="Customers" Select="it.[CustomerID]" OrderBy="it.[CustomerID]"> </asp:EntityDataSource> <asp:CheckBoxList ID="CustomerIdCheckBoxList" runat="server" DataSourceID="CustomerIdListEntityDataSource" DataTextField="CustomerID" DataValueField="CustomerID" RepeatDirection="Horizontal"> </asp:CheckBoxList> <asp:Button ID="cmdFilterCustomers" runat="server" Text="Apply Filter" /> </div> <% ''# you get this error passing in CSV in the where clause ''# The element type 'Edm.Int32' and the CollectionType 'Transient.collection[Edm.String(Nullable=True,DefaultValue=,MaxLength=,Unicode=,FixedLength=)]' are not compatible. The IN expression only supports entity, primitive, and reference types. Near WHERE predicate, line 6, column 15. ''# so have coded it manually in code-behind Where="it.CustomerID IN {@OrderIdList}" %> <asp:EntityDataSource ID="CustomersEntityDataSource" runat="server" ConnectionString="name=AdventureWorksLT2008Entities" DefaultContainerName="AdventureWorksLT2008Entities" EnableFlattening="False" EnableUpdate="True" EntitySetName="Customers" AutoGenerateOrderByClause="false"> </asp:EntityDataSource> <%''# updating works with DropDownLists until the Where clause is set in code %> <asp:FormView ID="FormView1" runat="server" AllowPaging="True" CellPadding="4" DataKeyNames="CustomerID" DataSourceID="CustomersEntityDataSource" ForeColor="#333333"> <EditItemTemplate> CustomerID: <asp:Label ID="CustomerIDLabel1" runat="server" Text='<%# Eval("CustomerID") %>' /> <br /> NameStyle: <asp:CheckBox ID="NameStyleCheckBox" runat="server" Checked='<%# Bind("NameStyle") %>' /> <br /> Title: <%''# the SelectedValue is not Bound to the EF object if the Where clause is updated in code-behind %> <asp:DropDownList ID="ddlTitleBound" runat="server" DataSourceID="TitleEntityDataSource" DataTextField="Title" DataValueField="Title" AutoPostBack="false" AppendDataBoundItems="true" SelectedValue='<%# Bind("Title") %>'> </asp:DropDownList> <asp:EntityDataSource ID="TitleEntityDataSource" runat="server" ConnectionString="name=AdventureWorksLT2008Entities" DefaultContainerName="AdventureWorksLT2008Entities" EnableFlattening="False" EntitySetName="Customers" Select="it.[Title]" GroupBy="it.[Title]" ViewStateMode="Enabled"> </asp:EntityDataSource> <br /> FirstName: <asp:TextBox ID="FirstNameTextBox" runat="server" Text='<%# Bind("FirstName") %>' /> <br /> MiddleName: <asp:TextBox ID="MiddleNameTextBox" runat="server" Text='<%# Bind("MiddleName") %>' /> <br /> LastName: <asp:TextBox ID="LastNameTextBox" runat="server" Text='<%# Bind("LastName") %>' /> <br /> Suffix: <asp:TextBox ID="SuffixTextBox" runat="server" Text='<%# Bind("Suffix") %>' /> <br /> CompanyName: <asp:TextBox ID="CompanyNameTextBox" runat="server" Text='<%# Bind("CompanyName") %>' /> <br /> SalesPerson: <asp:TextBox ID="SalesPersonTextBox" runat="server" Text='<%# Bind("SalesPerson") %>' /> <br /> EmailAddress: <asp:TextBox ID="EmailAddressTextBox" runat="server" Text='<%# Bind("EmailAddress") %>' /> <br /> Phone: <asp:TextBox ID="PhoneTextBox" runat="server" Text='<%# Bind("Phone") %>' /> <br /> PasswordHash: <asp:TextBox ID="PasswordHashTextBox" runat="server" Text='<%# Bind("PasswordHash") %>' /> <br /> PasswordSalt: <asp:TextBox ID="PasswordSaltTextBox" runat="server" Text='<%# Bind("PasswordSalt") %>' /> <br /> rowguid: <asp:TextBox ID="rowguidTextBox" runat="server" Text='<%# Bind("rowguid") %>' /> <br /> ModifiedDate: <asp:TextBox ID="ModifiedDateTextBox" runat="server" Text='<%# Bind("ModifiedDate") %>' /> <br /> <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" /> &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> </EditItemTemplate> <EditRowStyle BackColor="#999999" /> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <ItemTemplate> CustomerID: <asp:Label ID="CustomerIDLabel" runat="server" Text='<%# Eval("CustomerID") %>' /> <br /> NameStyle: <asp:CheckBox ID="NameStyleCheckBox" runat="server" Checked='<%# Bind("NameStyle") %>' Enabled="false" /> <br /> Title: <asp:Label ID="TitleLabel" runat="server" Text='<%# Bind("Title") %>' /> <br /> FirstName: <asp:Label ID="FirstNameLabel" runat="server" Text='<%# Bind("FirstName") %>' /> <br /> MiddleName: <asp:Label ID="MiddleNameLabel" runat="server" Text='<%# Bind("MiddleName") %>' /> <br /> LastName: <asp:Label ID="LastNameLabel" runat="server" Text='<%# Bind("LastName") %>' /> <br /> Suffix: <asp:Label ID="SuffixLabel" runat="server" Text='<%# Bind("Suffix") %>' /> <br /> CompanyName: <asp:Label ID="CompanyNameLabel" runat="server" Text='<%# Bind("CompanyName") %>' /> <br /> SalesPerson: <asp:Label ID="SalesPersonLabel" runat="server" Text='<%# Bind("SalesPerson") %>' /> <br /> EmailAddress: <asp:Label ID="EmailAddressLabel" runat="server" Text='<%# Bind("EmailAddress") %>' /> <br /> Phone: <asp:Label ID="PhoneLabel" runat="server" Text='<%# Bind("Phone") %>' /> <br /> PasswordHash: <asp:Label ID="PasswordHashLabel" runat="server" Text='<%# Bind("PasswordHash") %>' /> <br /> PasswordSalt: <asp:Label ID="PasswordSaltLabel" runat="server" Text='<%# Bind("PasswordSalt") %>' /> <br /> rowguid: <asp:Label ID="rowguidLabel" runat="server" Text='<%# Bind("rowguid") %>' /> <br /> ModifiedDate: <asp:Label ID="ModifiedDateLabel" runat="server" Text='<%# Bind("ModifiedDate") %>' /> <br /> <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" /> </ItemTemplate> <PagerSettings Position="Top" /> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> </asp:FormView> </form>

    Read the article

< Previous Page | 7 8 9 10 11