Help On Grid View filtering

Posted by Vijayar under C# on 7/27/2011 | Points: 10 | Views : 1932 | Status : [Member] | Replies : 5
Hi

i am binding values to grid view from a university table,and i have a dropdown to which i am types of universities and by selectong the types of universities i need to display those records with in the same gridview,Please help me to do this.Explain me how to do this

vijaya


Responses

Posted by: Vijayar on: 7/27/2011 [Member] Starter | Points: 25

Up
0
Down
Hi
I dont konow how to use inner grid view,please explain me in detail
i have dropdown out side of gridview,and i want to show the records based on the drop down selected value with in same grid
Ex

grid has 10 records with types fee,non fee,full part time
if i select non fee in dropdown i need to display only non fee university type records only,i am using varchar in database to store dropdown value


vijaya

Vijayar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gsudhesh on: 7/27/2011 [Member] Starter | Points: 25

Up
0
Down
write the Bind University details function in the search text box changed event.

Vijayar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A4u_6178 on: 7/27/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Vijayar,

I have created a table as University
create table university(UnivID int,UnivName varchar(90),UnivType varchar(90))

aspx code is as follows..
<asp:Label ID="Label1" runat="server" Text="Select University"></asp:Label>

<asp:DropDownList ID="DropDownList1" runat="server"
AutoPostBack="true"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Text="fee" Value="fee"/>
<asp:ListItem Text="nonfee" Value="nonfee"/>
<asp:ListItem Text="full part time" Value="full_part_time" Selected="true"/>
</asp:DropDownList>
<br />
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>

the codebehind to bind the gridview is
protected void Page_Load(object sender, EventArgs e)

{
if (!IsPostBack)
{
populategrid();
}
}
private void populategrid()
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Constr"].ConnectionString);
SqlDataAdapter sda = new SqlDataAdapter("select * from university", conn);
DataSet ds = new DataSet();
sda.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Constr"].ConnectionString);
//Label2.Text = DropDownList1.SelectedValue;
string filter = DropDownList1.SelectedValue;
SqlDataAdapter sda = new SqlDataAdapter("select * from university where UnivType='" + filter + "'", conn);
DataSet ds = new DataSet();
sda.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}

populategrid method is used here to fill the gridview from university table
on selectedindexchange em using the selected value as filter value to display only the required values into gridview..
I hope this helped u...

Thanks & Regards,

Vijayar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vijayar on: 7/29/2011 [Member] Starter | Points: 25

Up
0
Down
Hi
My problem is not how to bind,my imagebutton i am using is not getting fired.I am unable to trace the reason.Image button click event is not getting fired

vijaya

Vijayar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vijayar on: 7/29/2011 [Member] Starter | Points: 25

Up
0
Down
Hi


I need query to search records in such a way that when i enter a character in textbox it should dispaly the names which start with that character.How to do this.Please help me


vijaya

Vijayar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response