Click here to Skip to main content
Rate this: bad
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
Edited 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 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)

  Print Answers RSS
0 OriginalGriff 365
1 Prakriti Goyal 177
2 Sergey Alexandrovich Kryukov 155
3 jlopez788 144
4 _Amy 110
0 OriginalGriff 6,837
1 Sergey Alexandrovich Kryukov 5,559
2 Maciej Los 3,479
3 Peter Leow 3,323
4 DamithSL 2,505

Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | 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