Hello Telerik Team
I'm using RadControl version : 2011.1.315.35 (for ASP.NET AJAX). I am using the Radgrid control also.
I have a simple problem. I just want to load record in Radgrid control on selection of a value in Radcombobox.
Here is the code,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using Telerik.Web.UI;
public partial class GridDemo2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["connect"].ConnectionString))
{
using (SqlDataAdapter sda1 = new SqlDataAdapter())
{
string qry = "select * from Categories";
sda1.SelectCommand = new SqlCommand(qry, con1);
DataTable dt = new DataTable();
con1.Open();
try
{
sda1.Fill(dt);
RadGrid1.DataSource = dt;
}
catch (Exception ex) {
}
finally
{
con1.Close();
}
}
}
}
protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
if (IsPostBack)
{
using (SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["connect"].ConnectionString))
{
using (SqlDataAdapter sda1 = new SqlDataAdapter())
{
string qry = "select * from Categories where Category_Name = '" + RadComboBox1.SelectedValue.ToString() + "'";
sda1.SelectCommand = new SqlCommand(qry, con1);
DataTable dt = new DataTable();
con1.Open();
try
{
sda1.Fill(dt);
RadGrid1.DataSource = dt;
}
catch (Exception ex) {
}
finally
{
con1.Close();
}
}
}
}
}
In this example I have taken a radcombobox which is bind to Categories table and datafield value is category name.
I want to fill the rad grid when radcombobox value is selected. I am passing that value in the query and on that query i want to load that
record in the radgrid. I am not able to bind the data to radgrid.
If I am wrong in coding then please help me out.
Thanks in advance.
Regards
Anagha
I'm using RadControl version : 2011.1.315.35 (for ASP.NET AJAX). I am using the Radgrid control also.
I have a simple problem. I just want to load record in Radgrid control on selection of a value in Radcombobox.
Here is the code,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using Telerik.Web.UI;
public partial class GridDemo2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["connect"].ConnectionString))
{
using (SqlDataAdapter sda1 = new SqlDataAdapter())
{
string qry = "select * from Categories";
sda1.SelectCommand = new SqlCommand(qry, con1);
DataTable dt = new DataTable();
con1.Open();
try
{
sda1.Fill(dt);
RadGrid1.DataSource = dt;
}
catch (Exception ex) {
}
finally
{
con1.Close();
}
}
}
}
protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
if (IsPostBack)
{
using (SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["connect"].ConnectionString))
{
using (SqlDataAdapter sda1 = new SqlDataAdapter())
{
string qry = "select * from Categories where Category_Name = '" + RadComboBox1.SelectedValue.ToString() + "'";
sda1.SelectCommand = new SqlCommand(qry, con1);
DataTable dt = new DataTable();
con1.Open();
try
{
sda1.Fill(dt);
RadGrid1.DataSource = dt;
}
catch (Exception ex) {
}
finally
{
con1.Close();
}
}
}
}
}
In this example I have taken a radcombobox which is bind to Categories table and datafield value is category name.
I want to fill the rad grid when radcombobox value is selected. I am passing that value in the query and on that query i want to load that
record in the radgrid. I am not able to bind the data to radgrid.
If I am wrong in coding then please help me out.
Thanks in advance.
Regards
Anagha