Hi,
I am a fresher. i have a problem related to DataGrid .
i have a data grid and i have to place a dropdown in the
datagrid.and i have to retrieve the values from the database
(sqlserver).please tell me any idea about the code.

Answer Posted / ignatius

put the code inCODEFILE

public DataSet PopulateDDList()
{
string sqlString ="select
emp_name,emp_id from emp_current where
emp_des='"+Des.PM+"'";/*ANY*/
SqlDataAdapter ad = new
SqlDataAdapter(sqlString,new log().db);
DataSet ds = new DataSet();
ad.Fill(ds);
return ds;
}

in the follwing aspx

<EditItemTemplate>

<asp:DropDownList id=DropDownList1 runat="server"
DataSource="<%#PopulateDDList()%>" DataTextField="emp_name"
DataValueField="emp_id">

</asp:DropDownList>

</EditItemTemplate>

Actually this is work well

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can we create pie chart in asp.net?

805


How do you initiate validation on the server manually? What are two situations when you might you want to do that?

1570


Explain how can we inherit a static variable?

761


What is masterpage?

714


Describe the Server Control Events of ASP.NET?

882


Explain the difference between asp.net mvc and asp.net webforms? : asp.net mvc

756


What is the typical session identifier?

788


In a webservice, need to display 10 rows from a table. Which is the best choice among datareader or dataset?

877


To get the values in two different controls to match which control you use it?

787


How do I use response redirect?

732


Explain automatic memory management in .net.

776


Describe paging in asp.net?

880


What’s the difference between asp.net web forms and asp.net mvc?

791


Define the term Web Garden?

717


What are Master Pages in ASP.NET?

772