Saturday, October 24, 2015

Telerik Grid Master Details:


1 First add the reference of Telerik UI.
2 Design the form as follows:
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <div>
    <telerik:RadGrid ID="RadGrid1"  ShowStatusBar="true"
            DataSourceID="SqlDataSource1" runat="server"AutoGenerateColumns="False" PageSize="7"
            AllowSorting="True" AllowMultiRowSelection="False"AllowPaging="True" GridLines="None">
            <PagerStyle Mode="NumericPages"></PagerStyle>
            <MasterTableView EnableHierarchyExpandAll="true"DataSourceID="SqlDataSource1" DataKeyNames="CustomerID"AllowMultiColumnSorting="True">
                <DetailTables>
                    <telerik:GridTableViewEnableHierarchyExpandAll="true" DataKeyNames="OrderID"DataSourceID="SqlDataSource2" Width="100%"
                        runat="server">
                        <ParentTableRelation>
                            <telerik:GridRelationFieldsDetailKeyField="CustomerID" MasterKeyField="CustomerID"></telerik:GridRelationFields>
                        </ParentTableRelation>
                        <Columns>
                            <telerik:GridBoundColumnSortExpression="OrderID" HeaderText="OrderID"HeaderButtonType="TextButton"
                                DataField="OrderID"UniqueName="OrderID">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumnSortExpression="Date" HeaderText="Date Ordered"HeaderButtonType="TextButton"
                                DataField="Date" UniqueName="Date"DataFormatString="{0:D}">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumnSortExpression="Freight" HeaderText="Freight"HeaderButtonType="TextButton"
                                DataField="Freight"UniqueName="Freight">
                            </telerik:GridBoundColumn>
                        </Columns>
                        <SortExpressions>
                            <telerik:GridSortExpressionFieldName="Date"></telerik:GridSortExpression>
                        </SortExpressions>
                    </telerik:GridTableView>
                </DetailTables>
                <Columns>
                    <telerik:GridBoundColumnSortExpression="CustomerID" HeaderText="CustomerID"HeaderButtonType="TextButton"
                        DataField="CustomerID"UniqueName="CustomerID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumnSortExpression="ContactName" HeaderText="Contact Name"HeaderButtonType="TextButton"
                        DataField="ContactName"UniqueName="ContactName">
                    </telerik:GridBoundColumn>
                </Columns>
                <SortExpressions>
                    <telerik:GridSortExpressionFieldName="ContactName"></telerik:GridSortExpression>
                </SortExpressions>
            </MasterTableView>
        </telerik:RadGrid>
    <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="Data Source=ABC;Initial Catalog=ABC; User ID=sa;Password=abc"
        ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM Customers"
        runat="server"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="Data Source=ABC;Initial Catalog=ABC; User ID=sa;Password=abc"
        ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM Orders Where CustomerID = @CustomerID"
        runat="server">
        <SelectParameters>
            <asp:SessionParameter Name="CustomerID"SessionField="CustomerID" Type="string"></asp:SessionParameter>
        </SelectParameters>
    </asp:SqlDataSource>
    </div>
    </form>
</body>
Output:

Monday, March 9, 2015

Working with Drop Down list using MVC

File->New->Project



select : ASP.NET MVC 4- Application
AND CLICK ON OK


And select the project template and click on ok




And Go to Controller Folder and Right Click  AddController.




Go to  Controller and Select the Method Index and Right CLick on it.





and Now, go to Index.cshtml


and Write the following Code, ( this is binding Static Data)






Output:







Here, in the above example second parameter is  a collection of SelectListItem  which is used as Datasource for  DropDownList 



2  


public ActionResult Index()

        {
            List<string> ListItems = new List<string>();
            ListItems.Add("Select");
            ListItems.Add("India");
            ListItems.Add("a");
            ListItems.Add("d");
            ListItems.Add("d Africa");
            SelectList Countries = new SelectList(ListItems);
            ViewData["Countries"] = Countries;
            return View();
        }



Index.cshtml




Output:






3

With Model.


Now Go to Solution Explorer




And again go to solution explorer and add new item 
and add ado.net entity frame work




And click on add



Click on New Connection.






Give the Details and Click on Ok Button.






Click on Finish.





Controller.cs




public ActionResult Index()
        {
            RNDDatabaseEntities db = new RNDDatabaseEntities();
            ViewBag.Countries = new SelectList(db.Countries, "CountryID", "Countryname");
            return View();

        }


Index.cshtml


@model IEnumerable<MvcApplication3.Country>
@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

@Html.DropDownList("Countries", "Select")




Output:



4

Controller.cs

Index.cshtml






5





Index.cshtml


@model IEnumerable<MvcApplication3.Models.CountryModel>

@{
    ViewBag.Title = "Index";
}
<h2>Index</h2>
@Html.DropDownList("SelectedItem", (IEnumerable<SelectListItem>)ViewData["ListItems"])



output:




Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...