Click here to Skip to main content
15,917,062 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi
I am shailendra singh. Can any one help me.

I want to checked radio button and show data in gridview by function .
My following Function.

C#
public void FillGrid() 
  
 {
     string qry = "";
     if (rbtnstudnm.Checked)
{
qry = "Select StudentId,Name,FathersName,Class,Board,Category from tblStudReg  where Name ='" + txtstudname.Text.Trim() + "' and StudStatus='Active' Order By StudentId";
}
     if 
{
 (rbtnstudnm.Checked) qry = "Select StudentId,Name,FathersName,Class,Board,Category from tblStudReg  where name like '" + txtstudname.Text.Trim().Replace(" ", "%") + "%' and StudStatus='Active' Order By StudentId";
}
     
if (rbtnstudcls.Checked && drpalpha.SelectedValue == "All") 
{
qry = "select StudentId,Name,FathersName,Class,Board,Category from tblStudReg where Board='" + drpboard.SelectedValue.ToString() + "' and Class='" + drpclass.SelectedValue.ToString() + "' and Medium='" + drpmedium.SelectedValue.ToString() + "' and StudStatus='Active'  Order By StudentId";
}
     
if (rbtnstudcls.Checked && drpalpha.SelectedValue != "All")
{ 
qry = "select StudentId,Name,FathersName,Class,Board,Category from tblStudReg where Board='" + drpboard.SelectedValue.ToString() + "' and Class='" + drpclass.SelectedValue.ToString() + "' and Medium='" + drpmedium.SelectedValue.ToString() + "' and StudStatus='Active' and name like'" + drpalpha.SelectedValue.ToString() + "%' Order By StudentId";
}

     da = new SqlDataAdapter(qry, con);
     DataTable dt = new DataTable();
     //Response.Write(qry);
     da.Fill(dt);
     lblcount.Text = "No.Of Student Searched : " + Convert.ToString(dt.Rows.Count);
     GridView1.DataSource = dt;
     GridView1.DataBind();
    }

this my function please help me.

Thanks for advance.
Posted
Updated 11-Jan-12 21:40pm
v3
Comments
RDBurmon 12-Jan-12 3:09am    
What is error you are getting while executing this code ?
Supriya Srivastav 12-Jan-12 3:42am    
What's the problem?
anushripatil 12-Jan-12 4:04am    
what is the error that you are getting ?
KiranBabu M 12-Jan-12 6:03am    
can u specify clearly what the problem u r facing when u execute the above code.
Varun Sareen 12-Jan-12 12:11pm    
Please specify dear where you are getting the problem??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900