0
public static List<TemplateInfo> GetTemplateList()
    {
        DirectoryInfo dir = new DirectoryInfo("E://DotNetProjects//sftemplating//Templates");
        List<TemplateInfo> lstTemplates = new List<TemplateInfo>();
        foreach (DirectoryInfo temp in dir.GetDirectories())
        {
            TemplateInfo tempObj = new TemplateInfo(temp.Name);
            lstTemplates.Add(tempObj);
        }
        return lstTemplates;
     }

and

public void BindTemplate()
    {
        ddlTemplateList.DataSource = GetTemplateList();
        ddlTemplateList.DataBind();
    }

info is

public class TemplateInfo
    {
        public string TemplateName { get; set; }


        public TemplateInfo() { }        

        public TemplateInfo(string TemplateName)
        {
            this.TemplateName = TemplateName;

        }
    }

and i call BindTemplate in pageload like this

if (!IsPostBack)
        {
            BindTemplate();
        }

but ddlTemplateList is bind with Templating.TemplateInfo.Templating is my namespace.Whats my problem.Plz help to find my mistake.

3
  • are you getting error? can you check in debug weather GetTemplateList returns list what you wanted? Commented Oct 20, 2011 at 7:50
  • 1
    i think you have to set DataValueField & DataTextField for your dropdown list. ddlTemplateList. ddlTemplateList.DataTextField ="TemplateName"; ddlTemplateList.DataValueField = "TemplateName"; Commented Oct 20, 2011 at 7:52
  • @PragneshPatel ya i check in debug.Nothing error.I got a list which i want but ...................... Commented Oct 20, 2011 at 7:53

1 Answer 1

1

I think you miss to assgin thie

 ddlTemplateList.DataTextField="texttodisplay" ;
 ddlTemplateList.DataValueField="value";

You your code will be

public void BindTemplate()
{
    ddlTemplateList.DataSource = GetTemplateList();
    ddlTemplateList.DataTextField="texttodisplay" ;
    ddlTemplateList.DataValueField="value";
    ddlTemplateList.DataBind();
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.