Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
public partial class Default4 : System.Web.UI.Page
{
    adhousetier.clshouseinfo obj = new adhousetier.clshouseinfo();
    adhousetier.clsfxnhouse objfxn = new adhousetier.clsfxnhouse();
    List<adhousetier.clshouseinfo> objlst = new List<adhousetier.clshouseinfo>();

    private void bind()
    {
        objlst = objfxn.dspkitchen(obj);
       
        GridView1.DataSource = objlst;
        GridView1.DataBind();
        
    }
        protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bind();
        }

    }
}
 public List<clshouseinfo> dspkitchen(clshouseinfo r)
        {
            SqlCommand cmd = new SqlCommand("dspkitchen", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@kitchenid", SqlDbType.Int).Value = r.kitchenid;
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            List<clshouseinfo> lst = new List<clshouseinfo>();
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.HasRows)
            {
                dr.Read();
                clshouseinfo k = new clshouseinfo();
                k.image = dr[1].ToString();
                k.price = Convert.ToInt32(dr[2]);
                lst.Add(k);
            }
            cmd.Dispose();
            con.Close();
            return lst;
        }</clshouseinfo></clshouseinfo></clshouseinfo>

it is not binding the data to gridview can any one tell me the solution
Posted
Updated 3-Dec-10 21:32pm
v3
Comments
thatraja 4-Dec-10 3:33am    
Are you sure you got the data in "objlst"? If yes then include the error message in your question.
sandipapatel 4-Dec-10 3:37am    
Please provide if any error occurs.
Check the query & test it in inbuilt VS query builder.

Try : cmd.Parameters.Clear(); Always in program for efficiency & reducing error chances.

1 solution

If it's not binding then there may be chance that There's no data in Query result.

If not then provide full error message so that It can be easy for us to identify.

Thanks.
 
Share this answer
 
v2

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