1
Answer

Editable GridView contain dropdown list in ASP.NET

Arul R

Arul R

12y
3.7k
1
Hi Friends...

See more: C#ASP.NET
Hi Friends,,,
 
I have a grid view and inside the grid view Dropdown list there.
 
I want load data for dropdown list (username) from data base.
 
How can i do.
 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Viewstatus.aspx.cs" Inherits="Viewstatus" %>
 

<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
 
<%@ Register Src="include/Menu.ascx" TagName="Menu" TagPrefix="uc1" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <table align="center">
                    <tr>
                        <td>
                            <uc1:Menu ID="Menu1" runat="server" />
                        </td>
                    </tr>
                </table>
    <table cellpadding=2 width=100%>
   <tr>
   <td align="center">
  <asp:GridView ID="grid"  CssClass="grid"  runat="server"
           AutoGenerateColumns="False" onrowcancelingedit="grid_RowCancelingEdit"
           onrowdeleting="grid_RowDeleting" onrowediting="grid_RowEditing"
           onrowupdating="grid_RowUpdating" onrowdatabound="grid_RowDataBound" >
  <Columns>
  <asp:TemplateField HeaderText="Task ID">
                    <ItemTemplate>
                        <asp:Label ID="lbltaskid" runat="server" Text='<%#Bind("taskid")%>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="txttaskid" runat="server" Text='<%#Bind("taskid")%>'></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
 
   <asp:TemplateField HeaderText="Task Name">
                    <ItemTemplate>
                        <asp:Label ID="lbltask" runat="server" Text='<%#Bind("task")%>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="txttask" runat="server" Text='<%#Bind("task")%>'></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
 
                <asp:TemplateField HeaderText="Requester">
                    <ItemTemplate>
                        <asp:Label ID="lblreq" runat="server" Text='<%#Bind("reqfor")%>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="txtreq" runat="server" Text='<%#Bind("reqfor")%>'></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
 
                <asp:TemplateField HeaderText="Assigned To">
                    <ItemTemplate>
                        <asp:Label ID="lblasn" runat="server" Text='<%#Bind("Asssto")%>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                    <asp:DropDownList ID="dropuser" runat="server"    DataTextField ='<%#Bind("Asssto")%>'></asp:DropDownList>
                       <%-- <asp:TextBox ID="txtreq" runat="server" Text='<%#Bind("Asssto")%>'></asp:TextBox>--%>
                    </EditItemTemplate>
                </asp:TemplateField>
 
                <asp:TemplateField HeaderText="Date Time">
                    <ItemTemplate>
                        <asp:Label ID="lblDate" runat="server" Text='<%#Bind("datetime")%>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="txtdate" runat="server" Text='<%#Bind("datetime")%>'></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
 
                 <asp:TemplateField HeaderText="Estimated Time">
                    <ItemTemplate>
                        <asp:Label ID="lblest" runat="server" Text='<%#Bind("esttime")%>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="txtest" runat="server" Text='<%#Bind("esttime")%>'></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
                  <asp:TemplateField HeaderText="Status">
                    <ItemTemplate>
                        <asp:Label ID="lblsta" runat="server" Text='<%#Bind("status")%>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                    <asp:DropDownList ID="dropstatus" runat="server"  DataValueField='<%#Bind("status")%>' >
 
                    <asp:ListItem Text="Open" Value="Open" >  </asp:ListItem>
                    <asp:ListItem Text="Fixed" Value="Fixed"></asp:ListItem>
                     <asp:ListItem Text="Processing" Value="Processing"></asp:ListItem>
 
                    </asp:DropDownList>
                       <%-- <asp:TextBox ID="txtreq" runat="server" Text='<%#Bind("Asssto")%>'></asp:TextBox>--%>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ItemStyle-Width="50px" HeaderText="Edit">
                    <ItemTemplate>
                        <asp:LinkButton ID="lbtnedit" runat="server" ForeColor="#0C4375" Text="Edit" CommandName="Edit"></asp:LinkButton>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:LinkButton ID="lbtnupdate" runat="server" ForeColor="#0C4375" Text="Update"
                            CommandName="Update"></asp:LinkButton>
                        <asp:LinkButton ID="lbtncancel" runat="server" ForeColor="#0C4375" Text="Cancel"
                            CommandName="Cancel"></asp:LinkButton>
                    </EditItemTemplate>
                    <ItemStyle Width="50px"></ItemStyle>
                </asp:TemplateField>
                <asp:TemplateField ItemStyle-Width="50px" HeaderText="Delete">
                    <ItemTemplate>
                        <asp:LinkButton ID="lbtnDelete" runat="server" ForeColor="#0C4375" Text="Delete"
                            CommandName="Delete"></asp:LinkButton>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Left" Wrap="True" />
                    <ControlStyle BackColor="#EAF6FE" />
                </asp:TemplateField>
  </Columns>
 
  </asp:GridView>
   </td>
   </tr>
    </table>
 
    </form>
</body>
</html>
Answers (1)