<asp:TemplateField>
<HeaderTemplate>
Client
</HeaderTemplate>
<ItemTemplate>
<asp:Panel ID="pnlClient" runat="server">
<asp:DropDownList ID="ddlClient" runat="server" DataTextField="Clientname" DataValueField="clientid"
DataSource='<%#GetDSfDDL(Eval("client"))%>' AutoPostBack="True" OnSelectedIndexChanged="ddlClient_SelectedIndexChanged">
</asp:DropDownList>
</asp:Panel>
<%-- <asp:Label ID="lblClient" runat="server" Text='<%# bind("Client")%>'></asp:Label>--%>
</ItemTemplate>
<EditItemTemplate>
</EditItemTemplate>
</asp:TemplateField>
public List<clientddl> GetDSfDDL(object client)
{
List<clientddl> values = new List<clientddl>();
string[] cl = client.ToString().Split('/');
dt = new DataTable();
dt = bussclass.fnclientlist();
for (int i = 0; i < dt.Rows.Count; i++)
{
clientddl value = new clientddl();
value.Clientid = getint(dt.Rows[i]["client_id"]);
value.Clientname = dt.Rows[i]["client_name"].ToString();
values.Add(value);
}
for (int i = 0; i < values.Count; i++)
{
clientddl temp = new clientddl();
if (values[i].Clientid == getint(cl[0]))
{
if (i > 0)
{
temp = values[0];
values[0] = values[i];
values[i] = temp;
}
}
}
return values;
}