Hi SUJAYS,
Please refer below sample.
HTML
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" ItemStyle-Width="30" />
<asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" />
<asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-Width="150" />
<asp:CommandField ShowSelectButton="true" />
</Columns>
</asp:GridView>
<asp:DropDownList runat="server" ID="ddlId">
</asp:DropDownList>
<asp:DropDownList runat="server" ID="ddName">
</asp:DropDownList>
<asp:DropDownList runat="server" ID="ddlCountry">
</asp:DropDownList>
Namespaces
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)),
new DataColumn("Country",typeof(string)) });
dt.Rows.Add(1, "John Hammond", "United States");
dt.Rows.Add(2, "Mudassar Khan", "India");
dt.Rows.Add(3, "Suzanne Mathews", "France");
dt.Rows.Add(4, "Robert Schidner", "Russia");
GridView1.DataSource = dt;
GridView1.DataBind();
ddlId.DataSource = dt;
ddlId.DataTextField = "Id";
ddlId.DataValueField = "Id";
ddlId.DataBind();
ddName.DataSource = dt;
ddName.DataTextField = "Name";
ddName.DataValueField = "Name";
ddName.DataBind();
ddlCountry.DataSource = dt;
ddlCountry.DataTextField = "Country";
ddlCountry.DataValueField = "Country";
ddlCountry.DataBind();
ListItem select = new ListItem("Select", "0");
ddlId.Items.Insert(0, select);
ddName.Items.Insert(0, select);
ddlCountry.Items.Insert(0, select);
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = GridView1.SelectedRow;
ddlId.ClearSelection();
ddlId.Items.FindByText(row.Cells[0].Text).Selected = true;
ddName.ClearSelection();
ddName.Items.FindByText(row.Cells[1].Text.Trim()).Selected = true;
ddlCountry.ClearSelection();
ddlCountry.Items.FindByText(row.Cells[2].Text.Trim()).Selected = true;
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim dt As DataTable = New DataTable()
dt.Columns.AddRange(New DataColumn(2) {New DataColumn("Id", GetType(Integer)), New DataColumn("Name", GetType(String)), New DataColumn("Country", GetType(String))})
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
GridView1.DataSource = dt
GridView1.DataBind()
ddlId.DataSource = dt
ddlId.DataTextField = "Id"
ddlId.DataValueField = "Id"
ddlId.DataBind()
ddName.DataSource = dt
ddName.DataTextField = "Name"
ddName.DataValueField = "Name"
ddName.DataBind()
ddlCountry.DataSource = dt
ddlCountry.DataTextField = "Country"
ddlCountry.DataValueField = "Country"
ddlCountry.DataBind()
Dim select As ListItem = New ListItem("Select", "0")
ddlId.Items.Insert(0, select)
ddName.Items.Insert(0, select)
ddlCountry.Items.Insert(0, select)
End If
End Sub
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim row As GridViewRow = GridView1.SelectedRow
ddlId.ClearSelection()
ddlId.Items.FindByText(row.Cells(0).Text).Selected = True
ddName.ClearSelection()
ddName.Items.FindByText(row.Cells(1).Text.Trim()).Selected = True
ddlCountry.ClearSelection()
ddlCountry.Items.FindByText(row.Cells(2).Text.Trim()).Selected = True
End Sub
Screenshot