Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
//i am getting error:
 
//The type or namespace name 'var' could not be found (are you missing a using directive or an //assembly reference?)
 
//for this code what is the solution for that??
 
protected void gvUserInfo_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            con.Open();
 
            var ddl = (DropDownList)e.Row.FindControl("ddsponcor");
            string sponcorid = e.Row.Cells[0].Text;
            SqlCommand cmd = new SqlCommand("select sponcorid from Registration_Master where sponcorid=" + sponcorid, con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            con.Close();
            ddl.DataSource = ds;
            ddl.DataTextField = "sponcorid";
            ddl.DataValueField = "sponcorid";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("--Select--", "0"));
        }
    }
Posted 30-Nov-12 22:11pm
Edited 30-Nov-12 22:12pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can't use var here... Try with this:
DropDownList ddl = (DropDownList)e.Row.FindControl("ddsponcor");
  Permalink  
Comments
sumit kausalye at 1-Dec-12 4:17am
   
thank you it worked
Krunal Rohit at 1-Dec-12 5:59am
   
You're Welcome :)
__TR__ at 1-Dec-12 5:57am
   
My 5!
Krunal Rohit at 1-Dec-12 5:59am
   
Thanks man !

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



Advertise | Privacy | Mobile
Web04 | 2.8.141022.2 | Last Updated 1 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100