Click here to Skip to main content
12,555,894 members (47,308 online)
Rate this:
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)
            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();
            ddl.DataSource = ds;
            ddl.DataTextField = "sponcorid";
            ddl.DataValueField = "sponcorid";
            ddl.Items.Insert(0, new ListItem("--Select--", "0"));
Posted 30-Nov-12 22:11pm
Updated 30-Nov-12 22:12pm

1 solution

Rate this: bad
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");
sumit kausalye 1-Dec-12 4:17am
thank you it worked
Krunal Rohit 1-Dec-12 5:59am
You're Welcome :)
__TR__ 1-Dec-12 5:57am
My 5!
Krunal Rohit 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.161021.1 | Last Updated 1 Dec 2012
Copyright © CodeProject, 1999-2016
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