Hi every One

I am using FormView which is bound to EntityDataSource (VS 2008).

It is working Correctly when I Add data manually

But I want to add Dropdownlist which is bounded to another table Its Selected Value should be inserted in Database (Orginal Table of EntityDatasource).

How I accomblish this task

Dear,

Your problem is to bind the DropdownList control instead of regular Text or Label control. Isn't it?

I have replaced textbox with Dropdownlist and also bind the dropdownlist with an other entitydatasource. Now my problem is that When I click the insert button, The selected value of Drpdownlist should also be save in db.

Thanks
I have set. It is working
Problem is that When I insert data It through exception Primary Key Deos not allow null. Primary Key field is of GUID type. How I can provide a new GUID to Label Control in FormView

adatapost>Use the System.Guid class. The following code will help you.

SqlConnection cn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=c:\csnet\sample1\App_Data\Database.mdf;Integrated Security=True;User Instance=True");
        SqlCommand cmd = new SqlCommand("insert into emp values (@p1,@p2)", cn);
        cmd.Parameters.Add("@p1", SqlDbType.UniqueIdentifier, 32, "eno");
        cmd.Parameters.Add("@p2", SqlDbType.VarChar, 50, "ename");

        Guid g=Guid.NewGuid();

        cmd.Parameters[0].Value = g;  // GUID
        cmd.Parameters[1].Value = "R";

        cn.Open();
        cmd.ExecuteNonQuery();
        cn.Close();
This article has been dead for over six months. Start a new discussion instead.