Practical Web Applications for Daily Living…
ASP.net / Vb.net
I missed coding in Visual Studio.
Mar 13th
For two months now, I’ve been digging my way into the open source arena, php and mysql to be specific. I’ve been a full time asp.net csharp developer for more than two years already but now I am into magento and code igniter using LAMP servers. Even though coding in asp.net is a lot easier compare to developing in php (because of visual stdudio.) I still find being in open source now a days is a lot more practical if you and your clients are in the SME business front. For example, magento. I can’t create a system as powerful as magento for a short period of time even if I use asp.net. Yes there are also e-commerce platforms that uses asp.net like aspdotnetstorefront but it is very expensive and is too hard to customize. I used it to one of my clients before, And it was a pain to my ass tweaking its engine to meet the clients needs. Compared to magento, even a php beginner can customize it. I am not saying that I am leaving asp.net now, I can somehow use my experience of both sides to be more effective in my future projects.
How to Hide the Root Node in asp.net Menu Control
Nov 25th
Set ShowStartingNode=”false” in the SitemapDataSource control.
<asp:Menu ID="MenuControl" runat="server" Orientation="Horizontal"
DataSourceID="SiteMapDataSource1" StaticDisplayLevels="2">
</asp:Menu>
Casting Controls in Vb.net
Nov 24th
lblProdCode = DirectCast(e.Row.FindControl("lblProdCode"), Label)
lblProdCode.Text = ProductsGrid.DataKeys(e.Row.RowIndex).Values("ProdCode").ToString()
Dim lblProdName As New Label
lblProdName = DirectCast(e.Row.FindControl("lblProdName"), Label)
lblProdName.Text = ProductsGrid.DataKeys(e.Row.RowIndex).Values("ProdName").ToString()
Dim lblTotalItemSold As New Label
lblTotalItemSold = DirectCast(e.Row.FindControl("lblTotalItemSold"), Label)
lblTotalItemSold.Text = "999"
lblProdCode.Dispose()
lblProdName.Dispose()
lblTotalItemSold.Dispose()
Displaying (Generating) Index Number (Row Number) on your Gridview
Nov 24th
Put this in your Gridview…
<HeaderTemplate>
<asp:Label ID="Label4" runat="server" Text="Index #"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text=‘<%# Container.DataItemIndex + 1 %>‘></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" />
</asp:TemplateField>
The Code that generates the row index is
Handling Paging in Gridview in codebehind
Nov 24th
OrderGrid.PageIndex = e.NewPageIndex
OrderGrid.DataBind()
End Sub
Populating Gridview using Rowdatabound Event
Nov 24th
The Html Code
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="Label2" runat="server" Text="Order Total"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="OrderTotalTxt" runat="server" Text="Label"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="Label3" runat="server" Text="Order Date"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="OrderDateTxt" runat="server" Text="Label"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
the code behinde vb.net
Loading the Grid
OrderGrid.DataSource = ObjectOrder.GetOrdersAdminAll()
OrderGrid.DataBind()
End Sub
Populating during Rowdatabound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim OrderTotalTxt As New Label
OrderTotalTxt = DirectCast(e.Row.FindControl("OrderTotalTxt"), Label)
OrderTotalTxt.Text = OrderGrid.DataKeys(e.Row.RowIndex).Values("OrderTotal").ToString()
TotalAmount += Convert.ToDecimal(OrderTotalTxt.Text)
Dim OrderDateTxt As New Label
OrderDateTxt = DirectCast(e.Row.FindControl("OrderDateTxt"), Label)
OrderDateTxt.Text = OrderGrid.DataKeys(e.Row.RowIndex).Values("OrderDate").ToString()
OrderDateTxt.Dispose()
OrderTotalTxt.Dispose()
ElseIf e.Row.RowType = DataControlRowType.Footer Then
NumberOfOrders.Text = OrderGrid.Rows.Count()
TotalAmountofOrders.Text = "$ " & TotalAmount
End If
End Sub
Displaying Data in Gridview with Download to .xls Button, in vb.net
Nov 23rd
Aspx
Code Behind:
customers.DataSource = ObjOrders.GetOrderCustomer(Me.Page)
customers.DataBind()
End Sub
Public Overloads Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
End Sub
Protected Sub dataDownload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dataDownload.Click
Dim attachment As String = "attachment; filename=Contacts.xls" ‘name of the output .xls file
Response.ClearContent()
Response.AddHeader("content-disposition", attachment)
Response.ContentType = "application/ms-excel"
Dim sw As New StringWriter()
Dim htw As New HtmlTextWriter(sw)
customers.RenderControl(htw)
Response.Write(sw.ToString())
Response.[End]()
End Sub
Issues encountered in opening Asp.net MVC in different versions of Visual Studio.
Nov 17th
I have created a basic asp.net mvc structure using visual studio 2008 express edition, now when I open it using visual studio 2008 professional can’t open the the directory where my main MVC files are located, maybe its because the visual studio 2008 professional edition does not have MVC template installed in it?.. the pursuit continues…
Application Design Using Asp.net n-tier architecture techniques.
Nov 16th
Although Asp.net MVC (Model-View-Controller) is a promising framework many Asp.net Developer’s find it hard to transition and move. blahh .. blahhh.. blahhh….
