Dubli Join Us

Search About New Technology and Bug

Loading...

Thursday, March 26, 2015

Cascading DropDownLists Inside Telerik RadGrid

protected void RadComboBox1_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            // Get the Country DropDownList first.
            RadComboBox ddlBranch = (RadComboBox)sender;

            // Get the current GridView Row, from which the DropDownList is selected.
            GridEditableItem currentRow = (GridEditableItem)ddlBranch.NamingContainer;

            // Now let's find the City DropDownList on the same GridView Row.
            DropDownList ddlCity = (DropDownList)currentRow.FindControl("ddlAgent");

            if (ddlBranch != null && ddlBranch.SelectedIndex > 0 && ddlCity != null)
            {
                relife_part2Entities db = new relife_part2Entities();
                int? companyidfk=Convert.ToInt32(ddlBranch.SelectedValue);
                ddlCity.DataSource = db.tbl_policymaster.Where(x => x.companyidfk == companyidfk).ToList();
                ddlCity.DataTextField = "fullname";
                ddlCity.DataValueField = "policyID";
              
                ddlCity.DataBind();
                ddlCity.Items.Insert(0, "Select");
            }
            else if (ddlCity != null)
            {
                ddlCity.Items.Clear();
            }
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Get the Country DropDownList first.
            DropDownList ddlBranch = (DropDownList)sender;

            // Get the current GridView Row, from which the DropDownList is selected.
            GridEditableItem currentRow = (GridEditableItem)ddlBranch.NamingContainer;

            // Now let's find the City DropDownList on the same GridView Row.
            DropDownList ddlCity = (DropDownList)currentRow.FindControl("ddlAgent");

            if (ddlBranch != null && ddlBranch.SelectedIndex > 0 && ddlCity != null)
            {
                relife_part2Entities db = new relife_part2Entities();
                int? companyidfk = Convert.ToInt32(ddlBranch.SelectedValue);
                ddlCity.DataSource = db.tbl_policymaster.Where(x => x.companyidfk == companyidfk).ToList();
                ddlCity.DataTextField = "fullname";
                ddlCity.DataValueField = "policyID";

                ddlCity.DataBind();
                ddlCity.Items.Insert(0, "Select");
            }
            else if (ddlCity != null)
            {
                ddlCity.Items.Clear();
            }
        }


Html Code

  <div>
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"></telerik:RadAjaxManager>
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
            <telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowSorting="True" DataSourceID="SqlDataSource1" GroupPanelPosition="Top" AllowPaging="True" OnItemCommand="RadGrid1_ItemCommand">
                <MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1" EditMode="PopUp">
                   
                    <Columns>
                        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
                        </telerik:GridEditCommandColumn>
                        <telerik:GridBoundColumn DataField="agentcode" DataType="System.Int64" FilterControlAltText="Filter agentcode column" HeaderText="agentcode" SortExpression="agentcode" UniqueName="agentcode">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>

                        <telerik:GridBoundColumn DataField="agentname" FilterControlAltText="Filter agentname column" HeaderText="agentname" SortExpression="agentname" UniqueName="agentname">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="sponsorcode" DataType="System.Int64" FilterControlAltText="Filter sponsorcode column" HeaderText="sponsorcode" SortExpression="sponsorcode" UniqueName="sponsorcode">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>

                        <telerik:GridBoundColumn DataField="FatherName" FilterControlAltText="Filter FatherName column" HeaderText="FatherName" SortExpression="FatherName" UniqueName="FatherName">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="HusbandName" FilterControlAltText="Filter HusbandName column" HeaderText="HusbandName" SortExpression="HusbandName" UniqueName="HusbandName">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="PhoneNo" FilterControlAltText="Filter PhoneNo column" HeaderText="PhoneNo" SortExpression="PhoneNo" UniqueName="PhoneNo">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="MobileNo" FilterControlAltText="Filter MobileNo column" HeaderText="MobileNo" SortExpression="MobileNo" UniqueName="MobileNo">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>

                        <telerik:GridBoundColumn DataField="Rank" DataType="System.Int32" FilterControlAltText="Filter Rank column" HeaderText="Rank" SortExpression="Rank" UniqueName="Rank">
                            <ColumnValidationSettings>
                                <ModelErrorMessage Text="" />
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>


                    </Columns>
                    <EditFormSettings EditFormType="Template">
<EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column"></EditColumn>
                        <FormTemplate>
                            <table class="auto-style1">
                                <tr>
                                  <td>Branch</td>
                                    <td>
                                      
                                        <telerik:RadComboBox ID="RadComboBox1" Runat="server" DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="Id" AutoPostBack="True" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
                                        </telerik:RadComboBox>
                                       
                                    </td>
                                </tr>
                                <tr>
                                    <td>&nbsp;</td>
                                    <td>
                                        <asp:DropDownList ID="ddlAgent" runat="server">
                                        </asp:DropDownList>
                                    </td>
                                </tr>
                                <tr>
                                    <td>&nbsp;</td>
                                    <td>
                                        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="Id" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                                        </asp:DropDownList>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" Text="ddl1" ControlToValidate="DropDownList1" ErrorMessage="RequiredFieldValidator" InitialValue="0"></asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>&nbsp;</td>
                                    <td>
                                        <asp:Button ID="Button1" runat="server" Text="Button" />
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Text="agent" ControlToValidate="ddlAgent" ErrorMessage="RequiredFieldValidator" InitialValue="0"></asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                            </table>
                        </FormTemplate>
                    </EditFormSettings>
                </MasterTableView>
            </telerik:RadGrid>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:relife_part2ConnectionString %>" SelectCommand="SELECT * FROM [agent]"></asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:relife_part2ConnectionString %>" SelectCommand="SELECT * FROM [tbl_companyMaster]"></asp:SqlDataSource>
        </div>




http://www.telerik.com/support/code-library/export-radgrid-content-to-excel-word-csv-pdf-with-ajax-enabled

Tuesday, July 1, 2014

For Localize Datetime in Windows Application

  private void Form1_Load(object sender, EventArgs e)
        {

            // Creating a Global culture specific to our application.
            System.Globalization.CultureInfo cultureInfo =new System.Globalization.CultureInfo("en-US");
            // Creating the DateTime Information specific to our application.
            System.Globalization.DateTimeFormatInfo dateTimeInfo =
                new System.Globalization.DateTimeFormatInfo();
            // Defining various date and time formats.
            dateTimeInfo.DateSeparator = "/";
            dateTimeInfo.LongDatePattern = "dd-MMM-yyyy";
            dateTimeInfo.ShortDatePattern = "dd/MM/yyyy";
            dateTimeInfo.LongTimePattern = "hh:mm:ss tt";
            dateTimeInfo.ShortTimePattern = "hh:mm tt";
            // Setting application wide date time format.
            cultureInfo.DateTimeFormat = dateTimeInfo;
            // Assigning our custom Culture to the application.
            Application.CurrentCulture = cultureInfo;
            Thread.CurrentThread.CurrentCulture = cultureInfo;
            Thread.CurrentThread.CurrentUICulture = cultureInfo;

           
        }

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
           

            label1.Text = DateTime.ParseExact(dateTimePicker1.Value.Date.ToString("dd/MM/yyyy"), "dd/MM/yyyy" ,new CultureInfo("en-US"), DateTimeStyles.None).ToString();

            string dt = DateTime.ParseExact(dateTimePicker1.Value.Date.ToString("dd/MM/yyyy"), "dd/MM/yyyy", new CultureInfo("en-US"), DateTimeStyles.None).ToString("MM/dd/yyyy");
        }

Saturday, June 28, 2014

Good Css for HTML Table

<style type="text/css" >



/* Table 3 Style */
#tbl{
    font-family:Arial;
    font-size: 12px;
    font-style: normal;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: -1px;
    line-height: 1.7em;
    text-align:center;
    border-collapse:collapse;
}
#tbl thead th{
    padding:6px 10px;
    text-transform:uppercase;
    color:#444;
    font-weight:bold;
    text-shadow:1px 1px 1px #fff;
    border-bottom:5px solid #444;
}
#tbl thead th:empty{
    background:transparent;
    border:none;
}
#tbl thead :nth-child(2),
#tbl tfoot :nth-child(2){
    background-color: #7FD2FF;
}
#tbl tfoot :nth-child(2){
    -moz-border-radius:0px 0px 0px 5px;
    -webkit-border-bottom-left-radius:5px;
    border-bottom-left-radius:5px;
}
#tbl thead :nth-child(2){
    -moz-border-radius:5px 0px 0px 0px;
    -webkit-border-top-left-radius:5px;
    border-top-left-radius:5px;
}
#tbl thead :nth-child(3),
#tbl tfoot :nth-child(3){
    background-color: #45A8DF;
}
#tbl thead :nth-child(4),
#tbl tfoot :nth-child(4){
    background-color: #2388BF;
}
#tbl thead :nth-child(5),
#tbl tfoot :nth-child(5){
    background-color: #096A9F;
}
#tbl thead :nth-child(5){
    -moz-border-radius:0px 5px 0px 0px;
    -webkit-border-top-right-radius:5px;
    border-top-right-radius:5px;
}
#tbl tfoot :nth-child(5){
    -moz-border-radius:0px 0px 5px 0px;
    -webkit-border-bottom-right-radius:5px;
    border-bottom-right-radius:5px;
}
#tbl tfoot td{
    font-size:14px;
    font-weight:bold;
    padding:8px 0px;
    text-shadow:1px 1px 1px #fff;
}
#tbl tbody td{
    padding:8px;
}
#tbl tbody tr:nth-child(4) td{
    font-size:14px;
    font-weight:bold;
}
#tbl tbody td:nth-child(even){
    background-color:#444;
    color:#444;
    border-bottom:1px solid #444;
    background:-webkit-gradient(
        linear,
        left bottom,
        left top,
        color-stop(0.39, rgb(189,189,189)),
        color-stop(0.7, rgb(224,224,224))
        );
    background:-moz-linear-gradient(
        center bottom,
        rgb(189,189,189) 39%,
        rgb(224,224,224) 70%
        );
    text-shadow:1px 1px 1px #fff;
}
#tbl tbody td:nth-child(odd){
    background-color:#555;
    color:#f0f0f0;
    border-bottom:1px solid #444;
    background:-webkit-gradient(
        linear,
        left bottom,
        left top,
        color-stop(0.39, rgb(85,85,85)),
        color-stop(0.7, rgb(105,105,105))
        );
    background:-moz-linear-gradient(
        center bottom,
        rgb(85,85,85) 39%,
        rgb(105,105,105) 70%
        );
    text-shadow:1px 1px 1px #000;
}
#tbl tbody td:nth-last-child(1){
    border-right:1px solid #222;
}
#tbl tbody th{
    color:#696969;
    text-align:right;
    padding:0px 8px;
    border-right:1px solid #aaa;
}
img {

   display: block;
  -moz-box-sizing: border-box;

  background: url("images/check0.png");
  background-repeat:no-repeat;
  width: 70px; /* Width of new image */
  height: 50px; /* Height of new image */
  padding-left: 180px; /* Equal to width of new image */
   

}


</style>