Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
//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??

C#
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
Updated 30-Nov-12 22:12pm
v2

1 solution

You can't use var here... Try with this:
DropDownList ddl = (DropDownList)e.Row.FindControl("ddsponcor");
 
Share this answer
 
Comments
sumit kausalye 1-Dec-12 4:17am    
thank you it worked
[no name] 1-Dec-12 5:59am    
You're Welcome :)
__TR__ 1-Dec-12 5:57am    
My 5!
[no name] 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)



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