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> </td>
<td>
<asp:DropDownList ID="ddlAgent" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td> </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> </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
{
// 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> </td>
<td>
<asp:DropDownList ID="ddlAgent" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td> </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> </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
Thank you for sharing This knowledge. Excellently written article., if only all bloggers offered the same level of content as you, the internet would be a much better place. Please keep it up!
ReplyDeleteweb chat support