Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
T

TAK78

@TAK78
About
Posts
28
Topics
17
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Linq contains/split problem
    T TAK78

    I wrote a query which selects products from a defined category and than groups them by there material and product: Dim prod = From x In (From m In db.Products _ Where m.Subclass.Contains(category) _ Select New With {.Material = m.Material, .MarketingTitle = m.Marketing_title, .MarketingTagline = m.Marketing_tagline, .IDKey = m.Idkey, .ProductPhoto = m.Product_photo}) _ Group x By x.Material, x.ProductPhoto Into mg = Group _ Select mg It works perfectly so far. The "Subclass" is a string which holds all the possible categories the product falls in: "1, 3, 5, 7" (each number is a Category ID from the Category table) When I use the query from above where for sample "category" = 1. Than it will select all products which contain "1" of course, which also includes "10" or "100". Now is there a way that I can split this string and loop through that array to find the exact match so in my sample exactly "1" and ignore others? Here is a query I was trying but doesn't work: Dim prod = From x In (From m In db.Products _ Let subCat = m.Subclass.Split(", ") _ Where subCat.Distinct().ToString = category _ Select New With {.Material = m.Material, .MarketingTitle = m.Marketing_title, .MarketingTagline = m.Marketing_tagline, .IDKey = m.Idkey, .ProductPhoto = m.Product_photo}) _ Group x By x.Material, x.ProductPhoto Into mg = Group _ Select mg Any suggestions are appreciated Thanks

    LINQ database csharp linq data-structures sales

  • Grouping problem
    T TAK78

    OK, I found my problem and got it to work. In case someone else has the same problem, here is the solution that worked for me: Dim menu = From m In db.ProductCategories _ Select New With {.Title = m.CategoryName, _ .SubCategories = From s In m.ProductSubCategories _ Where s.MainCategoryID = m.ID _ Select s.SubCategoryName, s.ID} Thanks again

    LINQ help database csharp linq learning

  • Grouping problem
    T TAK78

    I have two tables "Categories" and "SubCategories". Category Table: ID: 1, 2, 3, 4, 5 ..... CatName: Cat1, Cat2, Cat3, Cat4, Cat5 .... SubCategories Table: ID: 1, 2, 3, 4, 5 ..... SubCatName: SubCat1, SubCat2, SubCat3, SubCat4, SubCat5 .... MainCatID: 1, 1, 3, 4, 1, 2 .... //the ID of the related Category for the subcategory Now I want to select all the Categories and also list the appropriate subcategorie within that category. Here is the query I wrote, but it shows an error on the "WHERE" clause: Dim menu = From m In db.ProductCategories _ Select New With {.Title = m.CategoryName, _ .SubCategories = From s In m.ProductSubCategories _ Where s.MainCategoryID = m.ProductSubCategories _ Select New With {.SubTitle = s.SubCategoryName}} For Each item In menu.ToArray() MsgBox(item.Title) For Each subT In item.SubCategories.ToArray() MsgBox(subT.SubTitle) Next Next I also tried this: Dim menu = From m In db.ProductCategories _ Select New With {.Title = m.CategoryName, _ .SubCategories = From s In m.ProductSubCategories _ Group s By m.ProductSubCategories Into Group _ Select New With {.SubTitle = Group}} I'm not sure what I'm doing wrong. Still a beginner with Linq and trying to learn. Any help and explanation is appreciated. Thanks

    LINQ help database csharp linq learning

  • Problem with Join and grouping
    T TAK78

    I got it to group now but I have trouble when trying to bind it to a Datalist Protected Sub LinqDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceSelectEventArgs) Handles LinqDataSource1.Selecting Dim prod = From x In (From m In db.ProductSpecs Join v In db.ProductVerbages On m.material Equals v.material _ Where m.subclass.Contains(ViewState("matcat")) _ Select New Product With {.Material = m.material, .MarketingTagline = v.marketing_tagline, .IDKey = m.idkey, .ProductPhoto = m.product_photo}) _ Group x By x.ProductPhoto Into mg = Group _ Select mg Dim pl As New List(Of Product) For Each item In prod.ToArray() pl = item.ToList 'MsgBox(item.ToString) 'For Each x In item.ToArray ' MsgBox(x.ProductPhoto) 'Next Next e.Result = pl End Sub Code for Datalist: <asp:DataList ID="DataList1" DataSourceID="LinqDataSource1" runat="server" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" GridLines="Vertical"> <FooterStyle BackColor="#CCCCCC" /> <SelectedItemStyle BackColor="#000099" Font-Bold="True" ForeColor="White" /> <ItemTemplate> <table> <tr> <td style="width:100px; font-weight:bold;"> <asp:ImageButton ID="Image1" Width="40" runat="server" ImageUrl='<%# "~/Images/ProductImages/" + Eval("ProductPhoto").toString() %>' /> <asp:Label ID="materialLabel" runat="server" Text='<%# Eval("Material") %>' /> </td> <td style="width:370px; padding-left: 5px; text-align: left;"> <asp:Label ID="Label" runat="server" TabIndex="1" Text='<%# Eval("MarketingTagline") %>' /> </td> <td style="width:80px; text-align:center;"> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("Material", "dataSheet.asp

    LINQ help database csharp linq sales

  • Problem with Join and grouping
    T TAK78

    I just started working with Linq a few days ago and I'm coming across a problem which gives me a hard time. I already searched many code samples online but I'm still having problems. I have two tables which are linked through material. I try to collect certain columns from each table of each material and than group the materials together which have the same picture. Here is one of the code samples I tried but it gives error on mg: (Definition of method mg is not accessible in this context) Dim db As New ZTDataDataContext Dim prod = From m In db.ProductSpecs Join v In db.ProductVerbages On m.material Equals v.material _ Where m.subclass.Contains(ViewState("matcat")) Group m By m.product_photo Into mg _ Select New Product With {.Material = m.material, _ .MarketingTagline = v.marketing_tagline, .IDKey = m.idkey, .ProductPhoto = m.product_photo} I'm not sure how I can get them into the group mg and than select all the other data. Would I need to create two query's or could I do it in one? Any help and explanation is very appreciated! Thanks Thomas

    LINQ help database csharp linq sales

  • SiteMapPath problem
    T TAK78

    I'm trying to build a sitemap so users can follow the path. My issue is that I can have multiple same landing pages of categories under different industries or products. Here is a sample of my sitemap: How could I create this without having to create like So it won't create an error? Would also not be efficient for programming. Please advise, I'm also open to other solutions. Thanks Thomas

    ASP.NET help question

  • Selecting multipe parameters
    T TAK78

    I'm trying to pass multiple DataKeynames after a selection is made in the Gridview, and to view them in a DataList where the selection matches them. Right now it will only display the first selected parameter (jacket). Here is my code:

    Visual Basic

  • Selecting multiple parameters
    T TAK78

    I'm trying to pass multiple DataKeynames after a selection is made in the Gridview, and to view them in a DataList where the selection matches them. Right now it will only display the first selected parameter (jacket). Here is my code:

    Web Development

  • Update Date
    T TAK78

    I'm trying to insert the new date when a selected Product is being updated. But I can't get it to insert the date. Here is my code:

    Visual Basic announcement

  • CSS sheets in folder
    T TAK78

    I wrote a code to check for Browser version and to set the Stylesheet accordingly. Now if I leave the Stylesheets at the root the code works perfect and selects the right style, but if I create a folder like "CSS" and put the styles in there and redirect the link to this folder than it want recognize the styles anymore. Can anyone tell me why? Here is my code: Public Function getStyle() As String Dim browser As Object = Request.Browser.Browser.ToLower.ToString() Dim bc As HttpBrowserCapabilities = Request.Browser Dim str As String = "" Dim Style As String = "" 'check browser and set appropriate stylesheet If browser = "ie" Then 'check for version of IE (6 or other) If bc.MajorVersion = "6" Then Response.Write("") 'Response.Write("") 'this line want work Else Response.Write("") 'Response.Write("") 'this line want work End If Else Response.Write("") 'Response.Write("") 'this line want work End If Return Style End Function code in Html header: Untitled Page <% getStyle() %> I appreciate any suggestion. Thanks

    ASP.NET html css wpf question announcement

  • Problem getting value
    T TAK78

    There is no problem finding the TitleLink or the TextLink and to set the value for it. It's only when I start looking for the HtmlInputHidden!!!

    Visual Basic help design question

  • Problem getting value
    T TAK78

    I'm trying to access the value of a HtmlInputHidden inside a datalist, but I get "Object reference not set to an instance of an object" as an error when I try to call the value. Here is my code: Protected Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList1.ItemDataBound Select Case e.Item.ItemType Case ListItemType.Item, ListItemType.AlternatingItem 'Dim row As DataRowView = CType(e.Item.DataItem, DataRowView) Dim TitleLink As HyperLink = CType(e.Item.FindControl("ProdTitleLink"), HyperLink) Dim TextLink As HyperLink = CType(e.Item.FindControl("ProdTextLink"), HyperLink) Dim prodID As HtmlInputHidden = CType(e.Item.FindControl("ProductID"), HtmlInputHidden) TextLink.NavigateUrl = "productDetails.aspx?catID=" & Request.QueryString("catID") & "Id" & prodID.Value TitleLink.NavigateUrl = "productDetails.aspx?catID=" & Request.QueryString("catID") & "Id" & prodID.Value End Select End Sub Code of Datalist:

    Product

    Qty

    Price

    Visual Basic help design question

  • Problem accessing HtmlInputHidden
    T TAK78

    I'm trying to access the value of a HtmlInputHidden inside a datalist, but I get "Object reference not set to an instance of an object" as an error when I try to call the value. Here is my code: Protected Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList1.ItemDataBound Select Case e.Item.ItemType Case ListItemType.Item, ListItemType.AlternatingItem 'Dim row As DataRowView = CType(e.Item.DataItem, DataRowView) Dim TitleLink As HyperLink = CType(e.Item.FindControl("ProdTitleLink"), HyperLink) Dim TextLink As HyperLink = CType(e.Item.FindControl("ProdTextLink"), HyperLink) Dim prodID As HtmlInputHidden = CType(e.Item.FindControl("ProductID"), HtmlInputHidden) TextLink.NavigateUrl = "productDetails.aspx?catID=" & Request.QueryString("catID") & "Id" & prodID.Value TitleLink.NavigateUrl = "productDetails.aspx?catID=" & Request.QueryString("catID") & "Id" & prodID.Value End Select End Sub Code of Datalist:

    Product

    Qty

    Price

    ASP.NET help design question

  • Problem passing data to javascript
    T TAK78

    Thanks a lot works perfect now!!! So problem was that you have to encode the special characters before you pass it on, right? Thanks for the help and advice

    ASP.NET help javascript database tools

  • Problem passing data to javascript
    T TAK78

    I'm retrieving data from the database and try to pass it on to a javascript function so I can process it. I get a javascript error when I try to pass the value. Here is my code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim val As String = CType(FormView2.FindControl("ImgList"), HtmlInputHidden).Value MsgBox(val) Dim script As String = "" script = "" script &= "var str = String(" & val & ");" script &= "alert(str);" script &= "setImageArr(" & str & ");" script &= "" Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "SetList", script) End Sub When I check via MsgBox the right value shows, but it want show in the javascript. Any suggestions. Thanks

    ASP.NET help javascript database tools

  • Problems with data
    T TAK78

    I have a database in which I store the items that a customer added to the shoppingcart. Now I try to get the data and put it into the shoppingcart when the user loggs back in and there were items he didn't purchased yet but left in cart last time he was logged. It will display the right quantity of each product, but it shows the Name and price of last recieved product in my ShoppingCart display on all products. Here is code I have so far for getting items from DB and adding to ShoppingCart: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Membership.GetUser() Is Nothing Then StoreManager.ShoppingCart.UserID = Membership.GetUser().UserName If Not Session("Logged") Then StoreDB.GetShoppingCart(Membership.GetUser().UserName) Session("Logged") = True End If Else HttpContext.Current.Session("ShoppingCart") = New ShoppingCart() StoreManager.ShoppingCart.UserID = "" Session("Logged") = False End If End Sub Public Shared Sub GetShoppingCart(ByVal userID As String) Try Using myCon As New SqlConnection(AppConnection.ConnectionString) Dim myCom As SqlCommand = New SqlCommand("sprocGetShoppingCartItems", myCon) myCom.CommandType = CommandType.StoredProcedure myCom.Parameters.AddWithValue("@cartID", userID) Dim prod As Product = New Product Dim qty As Integer = 0 myCon.Open() Using myRd As SqlDataReader = myCom.ExecuteReader(CommandBehavior.CloseConnection) While myRd.Read() prod.CategorieID = myRd.GetInt32(myRd.GetOrdinal("CategorieID")) prod.ProductID = myRd.GetInt32(myRd.GetOrdinal("ProductID")) prod.ProductName = myRd.GetString(myRd.GetOrdinal("ProductName")) prod.ProductPrice = myRd.GetDecimal(myRd.GetOrdinal("ProductPrice")) prod.ProductMini = myRd.GetString(myRd.GetOrdinal("ProductImage")) prod.Qty = myRd.GetInt32(myRd.GetOrdinal("Quantity")) MsgBox("Adding: " & prod.ProductName) StoreManager.ShoppingCart.AddDB(prod, prod.Qty) End While myRd.Close() End Using End Using Catch ex As Exception ' error

    ASP.NET database sales help

  • Deleting multiple rows
    T TAK78

    Ok, found the problem and fixed it: Public Sub Remove(ByVal id As Guid) For i As Integer = _items.Count - 1 To 0 Step -1 Dim existingProd As OrderedProducts = _items(i) If id = existingProd.ID Then MsgBox("Found Product! Count: " & _items.Count.ToString() & "items") _items.Remove(existingProd) MsgBox("Deleted Product! Count: " & _items.Count.ToString() & "items") End If Next End Sub Thanks a lot!!!

    Visual Basic help tutorial

  • Deleting multiple rows
    T TAK78

    Hmmm, I tried this but still get same error For i As Integer = GridView1.Rows.Count - 1 To 0 Step -1 Dim row As GridViewRow = GridView1.Rows(i) Dim chk As CheckBox = CType(row.FindControl("Remove"), CheckBox) If Not chk Is Nothing AndAlso chk.Checked Then Dim ID = New Guid(GridView1.DataKeys(row.RowIndex).Value.ToString()) StoreManager.RemoveItem(ID) End If Next

    Visual Basic help tutorial

  • Deleting multiple rows
    T TAK78

    I'm working on a shoppingCart and try to delete multiple rows at once, but get error message: "Collection was modified; enumeration operation may not execute." Here is my code: Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpdate.Click For Each row As GridViewRow In GridView1.Rows Dim chk As CheckBox = CType(row.FindControl("Remove"), CheckBox) If Not chk Is Nothing AndAlso chk.Checked Then Dim ID = New Guid(GridView1.DataKeys(row.RowIndex).Value.ToString()) StoreManager.RemoveItem(ID) End If Next End Sub Code for: Class StoreManager Public Shared Sub RemoveItem(ByVal id As Guid) ShoppingCart.Remove(id) End Sub Code for: Class ShoppingCart Public Sub Remove(ByVal id As Guid) For Each existingProd As OrderedProducts In _items If id = existingProd.ID Then _items.Remove(existingProd) End If Next 'error calls this line!!! End Sub Not sure how to fix error!

    Visual Basic help tutorial

  • Finding control
    T TAK78

    Found the solution: Protected Sub submitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitBtn.Click Dim errMsg As String = "" Dim ctHolder As ContentPlaceHolder ctHolder = CType(Master.FindControl("ContentPlaceHolder1"), ContentPlaceHolder) For Each ctrl As Control In ctHolder.Controls If TypeOf ctrl Is TextBox Then errMsg &= "Found it!" & ctrl.ID.ToString() & "
    " End If Next msgText.Text = errMsg End Sub Thanks so for the suggestion!

    ASP.NET debugging
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups