In this example I will give you a complete solution on “How to operate Drop Down List in Grid View Edit Mode“ CREATE TABLE [dbo].[Brand]( [ID] [bigint] NOT NULL, [Name] [varchar](max) NOT NULL, CONSTRAINT [PK_Brand] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] CREATE TABLE [dbo].[Product]( [ID] [bigint] NOT NULL, [Name] [varchar](max) NULL, [Description] [varchar](max) NULL, [Brand ID] [bigint] NULL, CONSTRAINT [PK_Product_2] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] INSERT INTO Brand Values(1,'Kohinoor') INSERT INTO Brand Values(2,'Proctor & Gamble') INSERT INTO Brand Values(3,'Telenor') INSERT INTO Brand Values(4,'Unilever') INSERT INTO PRODUCT VALUES(1,'Lux Beauty Soap','Product of Unilever',4) INSERT INTO PRODUCT VALUES(2,'Tibbet Pomed','Winter Product',1) INSERT INTO PRODUCT VALUES(3,'Data SIM','Subscriber Identity Module',3) INSERT INTO PRODUCT VALUES(4,'Nippon','Color Television',1) Note: If you use windows authentication then use the first key. Update server name, Database name, User name, Password as per your settings. Is Post Back) { Bind Grid View(); } } private void Bind Grid View() { Data Table dt; String SQL = "SELECT P. Now add the Grid View Control like Below: Note: If you look at the Grid View events you will get onrowdatabound, onrowupdating, onrowediting, onrowcancelingedit events. Like onrowdatabound event will fire when Grid View Data Bind() method was called, onrowediting event will fire when user click on Edit link, onrowupdating event will fire when user click on Update link & onrowcancelingedit will fire when user click on Cancel link.

aspdotnet-suresh offers C#articles and tutorials,csharp dot net,articles and tutorials, VB.

Grid View displays the values of a data source in a table where each column represents a field and each row represents a record.

It enables you to select, sort, and edit these items.

In this article, I am going to explain how to insert, update or delete a row from a grid view control. At run time, the Eval method calls the Eval method of the Data Binder object.

If you are new to using a grid control, I would recommend you to read my blogs “Using Grid View in ASP. The Eval method takes the name of a data field and returns a string containing the value of that field from the current record in the data source.

Net) developers faced a problem when they want to implement edit functionality within a Grid View. Name Brand" + " FROM Product P, Brand B" + " WHERE P. The problem is developers can not understand how to populate or bind data into Drop Down List within the Grid View in Edit Mode. The another problem is after populating how to display or show current database value by default in Drop Down List as a Selected Value in edit mode. Now first Bind or Load the Grid View Control: C# Code: protected void Page_Load(object sender, Event Args e) { if (! Connection String; using (Sql Connection conn = new Sql Connection(s Constr)) { using (Sql Command comm = new Sql Command(SQL, conn)) { conn. Data Bind(); } Protected Sub Page_Load(sender As Object, e As System. Load If Not Is Post Back Then Bind Grid View() End If End Sub Private Sub Bind Grid View() Dim dt As Data Table Dim SQL As String = "SELECT P. Open() Using da As Sql Data Adapter = New Sql Data Adapter(comm) dt = New Data Table("tbl") da. Open(); using (Sql Data Adapter da = new Sql Data Adapter(comm)) { dt = new Data Table("tbl"); da. Name Brand" + " FROM Product P, Brand B" + " WHERE P. ID" Dim s Constr As String = Configuration Manager. Connection String Using conn As Sql Connection = New Sql Connection(s Constr) Using comm As Sql Command = New Sql Command(SQL, conn) conn. Data Bind() End Sub 0) { Drop Down List cbo Brand = (Drop Down List)e. Find Control("cbo Brand"); Data Table dt; String SQL = "SELECT * FROM Brand"; string s Constr = Configuration Manager. Connection String; using (Sql Connection conn = new Sql Connection(s Constr)) { using (Sql Command comm = new Sql Command(SQL, conn)) { conn.