Apr 2, 2012

Show Images dynamically in asp.net


<asp:sqlDataSource ID="ImgSqlDataSource" SelectCommand="SELECT imageName, 
imageUrl FROM tblImages" />

<asp:Repeater id="cdcatalog" runat="server">
    <HeaderTemplate>
        <table>
    </HeaderTemplate>
    <ItemTemplate>
        <tr>
            <td><img src="<%#Container.DataItem("imageUrl")%>" /></td>
        </tr>
        <tr>
             <td><%#Container.DataItem("imageUrl")%></td>
        </tr>
    </ItemTemplate>
    <FooterTemplate>
        </table>
    </FooterTemplate>
</asp:Repeater>

============================
IN Source Code PAge...

onPageLoad provide ImgSqlDataSource to the repeter Control.

Mar 10, 2012

VistaDB is an Embedded SQL Database Engine for .Net

VistaDB is the only .Net embedded database that allows you to Xcopy a single DLL for both 32 and 64 bit runtime support.  Want ClickOnce deployment for your .Net application?  VistaDB requires zero config on the client.  No more worries about COM deployment for the database engine!  Even our database files are built for ease of deployment - a single database file with no external logs or complex permissions.

No need to bother your hosting provider for special access, no services to run.



Full integration within Visual Studio Standard or Higher



Work with Visual Studio 2008 and 2010


VistaDB has full Visual Studio integration giving you the familiar tools you need to be productive quickly, including full Server Explorer integration.   Developers who have used other desktop databases in Visual Studio will be able to immediately start working with VistaDB.

Feb 13, 2012

Add Row Number in Query

SELECT ROW_NUMBER () OVER ( ORDER BY com_code )
       ,*
FROM   Mcompany

How to add Nested repeter controls and create Dynamic own view template



===================== Design Page ==========================

 <TABLE style="WIDTH: 500px"><TBODY><TR><TD align=left><DIV align=center><asp:Label id="lblMsg" runat="server" SkinID="msgerror"></asp:Label> </DIV></TD></TR><TR><TD align=left></TD></TR><TR><TD colSpan=2><DIV style="DISPLAY: none" id="grid"><asp:Repeater id="parentRepeater" runat="server" __designer:dtid="3377699720527899" __designer:wfdid="w1">
                                        <ItemTemplate __designer:dtid="3377699720527900">
                                            <table style="border-right: #66cc66 1px solid; border-top: #66cc66 1px solid; border-left: #66cc66 1px solid;
                                    border-bottom: #66cc66 1px solid" cellspacing="0" cellpadding="0" width="100%">
                                            <tr __designer:dtid="3377699720527901"  class="collapsible-item">

                                                <td __designer:dtid="3377699720527902" class="collapsible-item-title" align="left" colspan="4" style="border-right: gainsboro 2px solid;
                                                    border-top: gainsboro 2px solid; border-left: gainsboro 2px solid; border-bottom: gainsboro 2px solid;
                                                    color: #0190D0; font-family: Verdana; font-size: 8.5pt; font-weight: bold; height: 20px;
                                                    background-color: gainsboro;">                                                 
                                                 
                                                    <div class="item-title-header">  </div> &nbsp;
                                                    <img src="../../App_Themes/images/gvCollapsedButton.png" alt="Expand this section" class="toggle-button">
                                                      
                                                         <b>&nbsp; &nbsp;
                                                              <asp:Hyperlink runat= "server" ForeColor="#0190D0" Text='<%# DataBinder.Eval(Container.DataItem,"vProductName").tostring%>'
                                                              NavigateUrl='<%# "FrmMarketCompet.aspx?ProjectID=" & DataBinder.Eval (Container.DataItem,"nProjectId").tostring & _
                                                              "&ProductID=" & DataBinder.Eval(Container.DataItem,"nMarketProdId").tostring %>' ID="ProductName" ToolTip="Click to see products details."/>
                                                        </b>
                                                 
                                                  
                                                 
                                                </td>
                                            </tr>
                                            <tr style="display: none;" class="togglethis">
                                            <td>
                                            <asp:Repeater __designer:dtid="3377699720527904" ID="childRepeater" runat="server"
                                                DataSource='<%# Container.DataItem.Row.GetChildRows("myrelation") %>'>
                                                <ItemTemplate __designer:dtid="3377699720527905">
                                                                 <TABLE style="WIDTH: 100%;BORDER-BOTTOM: lightgrey 1px solid; font-family: Verdana; font-size: 8pt;" cellSpacing=0 cellPadding=3><TBODY>
                                                                 <TR>
                                                                 <TD><asp:Label id="LblYear" runat="server" Text='<%#Container.DataItem("vMarketProdYear") %>' SkinID="Heading" Width="150px"></asp:Label></TD>
                                                                 <TD style="BORDER-LEFT: lightgrey 1px solid" align=center><asp:Label id="Label1" runat="server" Text="Market " SkinID="Heading"></asp:Label></TD>
                                                                 <TD style="BORDER-LEFT: lightgrey 1px solid; BORDER-BOTTOM: lightgrey 1px solid" align=right><asp:Label id="Label7" runat="server" Text="Qty :" SkinID="Heading"></asp:Label></TD>
                                                                 <TD><asp:Label style="TEXT-ALIGN: right" width="80px" id="txtMarketQty"  runat="server" Text='<%#Container.DataItem("fMarketQty") %>'></asp:Label></TD>
                                                                 </TR>
                                                                 <TR>
                                                                 <TD></TD>
                                                                 <TD style="BORDER-LEFT: lightgrey 1px solid; BORDER-BOTTOM: lightgrey 1px solid" align=right></TD>
                                                                 <TD style="BORDER-LEFT: lightgrey 1px solid; BORDER-BOTTOM: lightgrey 1px solid" align=right><asp:Label id="Label4" runat="server" Text="Value :" SkinID="Heading"></asp:Label></TD>
                                                                 <TD style="BORDER-BOTTOM: lightgrey 1px solid"><asp:Label style="TEXT-ALIGN: right" id="txtMarketValue"  width="80px" runat="server" Text='<%#Container.DataItem("fMarketValue") %>'></asp:Label></TD>
                                                                 </TR>
                                                                 <TR>
                                                                 <TD ></TD>
                                                                 <TD style="BORDER-LEFT: lightgrey 1px solid" align=center><asp:Label id="Label8" runat="server" Text="CGL Share" SkinID="Heading" Width="78px"></asp:Label></TD>
                                                                 <TD style="BORDER-LEFT: lightgrey 1px solid; BORDER-BOTTOM: lightgrey 1px solid" align=right><asp:Label id="Label6" runat="server" Text="Value :" SkinID="Heading" Width="80px"></asp:Label></TD>
                                                                 <TD><asp:Label  style="TEXT-ALIGN: right" id="TxtCglValue"  width="80px" runat="server"  Text='<%#Container.DataItem("fCGValue") %>'></asp:Label></TD>
                                                                 </TR>
                                                                 <TR>
                                                                 <TD style="BORDER-BOTTOM: lightgrey 1px solid;"></TD>
                                                                 <TD style="BORDER-LEFT: lightgrey 1px solid; BORDER-BOTTOM: lightgrey 1px solid" align=right></TD>
                                                                 <TD style="BORDER-LEFT: lightgrey 1px solid; BORDER-BOTTOM: lightgrey 1px solid" align=right><asp:Label id="Label5" runat="server" Text="% :" SkinID="Heading"></asp:Label></TD>
                                                                 <TD style="BORDER-BOTTOM: lightgrey 1px solid;"><asp:Label style="TEXT-ALIGN: right" id="txtCGLPercent"  width="80px" runat="server" Text='<%#Container.DataItem("fCGPercentage") %>'></asp:Label></TD>
                                                                 </TR></TBODY>
                                                                 </TABLE>                                         
                                                   
                                                    
                                                
                                                </ItemTemplate>
                                            </asp:Repeater>
                                              </td>
                                              </tr>
                                              </table>
                                        </ItemTemplate>
                                    </asp:Repeater> </DIV></TD></TR><TR><TD align=center colSpan=2><asp:Button accessKey="s" id="btnAddnew" tabIndex=11 onclick="btnAddnew_Click" runat="server" Text="Add New" ToolTip="Add New"></asp:Button>&nbsp;<asp:Button id="BtnContinue" onclick="BtnContinue_Click" runat="server" Text="Continue" __designer:wfdid="w2"></asp:Button></TD></TR></TBODY>
                                  
                                    </TABLE>



 <script language="text/javascript" src="../../Common/jquery-1.6.2.min.js" type="text/javascript"></script>

    <script type="text/javascript">
    $(document).ready(function () {

    $.fn.toggleTo = function( options ) {
        options = $.extend( options, {
        containerClass:'collapsible-item',
        speed:'slow',
        collapse:'../../App_Themes/images/gvExpandedButton.png',
        expand:'../../App_Themes/images/gvCollapsedButton.png',
        toggleClass:'togglethis'
        });

        return this.each(function() {

        var p = $(this).closest('.' + options.containerClass);

        $(this).toggle(function() {
            $(p).find('.toggle-button').attr('src', options.collapse);
            $(p).next('.' + options.toggleClass).slideToggle('slow');
        }, function() {
            $(p).find('.toggle-button').attr('src', options.expand);
            $(p).next('.' + options.toggleClass).slideToggle('slow');
        });
        });
    }

    $('.item-title-header, .toggle-button').toggleTo();
   });




function pageLoad(sender, args)
{
    if (args.get_isPartialLoad())
    {
        //alert('Ajax call');
     
        $("#grid").show("fast");
        $(".Child").hide("fast");
       
    }
    else
    {
        //alert('PostBack or initial load');
    
        $("#grid").show("fast");
        $(".Child").hide("fast");
      
    }
}




function HideAll(obj)
{
    //alert('call');
   
    var obj2=obj.parentElement.children(1);
    $(obj2).slideToggle("slow");
  
    //$("#A").animate({width: "200px" , height: "10px"}, "200");  
}



    </script>
======================= Code Behind ===========================


 Private Sub GetBusEvaGrid()
        Try

     Dim ds As DataSet = objProd.GetAllProducts(HiddenProjectId.Value)
            ds.Relations.Add("myrelation", ds.Tables(0).Columns("nMarketProdId"), ds.Tables(1).Columns("nMarketProdId"))
            parentRepeater.DataSource = ds.Tables(0)
            parentRepeater.DataBind()


        Catch ex As Exception

        End Try



' SAVE Code

Protected Sub BtnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Try


            lblMsg.Text = ""

            If Session("Userid") = Nothing Or Session("Userid") = "" Then
                lblMsg.Text = "login user id not found"
                Return
            End If

            If Not HiddenProjID.Value = "" And Not HiddenPreqDetailsID.Value = "" Then
                For i As Integer = 0 To parentRepeater.Items.Count - 1
                    ObjBusEva.ProjectID = Int32.Parse(HiddenProjID.Value)
                    ObjBusEva.PreqDetailsID = Int32.Parse(HiddenPreqDetailsID.Value)

                    Dim ChildRep As Repeater = TryCast(parentRepeater.Controls(i).Controls(1), Repeater)

                    If IsNothing(ChildRep) = False Then
                        For Each item As RepeaterItem In ChildRep.Items


                            Dim HidSecId As HiddenField = DirectCast(item.FindControl("HidSecId"), HiddenField)
                            ObjBusEva.SectionId = HidSecId.Value

                            Dim HidPartId As HiddenField = DirectCast(item.FindControl("HidPartId"), HiddenField)
                            ObjBusEva.ParticularsId = HidPartId.Value

                            Dim txtVal As TextBox = DirectCast(item.FindControl("TxtVal"), TextBox)
                            ObjBusEva.Value = txtVal.Text

                            ObjBusEva.SaveBusAnalys()
                        Next

                    End If

                Next

                lblMsg.Text = "Data save successfully."
            End If




        Catch ex As Exception
            lblMsg.Text = ex.Message
        End Try
    End Sub




What is the use of n-tier architecture and 3-tier architecture?

how to implement 3-tier architecture in asp.net using c#. 3-Tier architecture is also called layered architecture. Some people called it ...