开发者

In asp.net how to add meno or dropdown control in asp.net?

开发者 https://www.devze.com 2023-03-08 00:52 出处:网络
Data gridview bind the recored with data set.Gird view consist the column \"Compnayname\" whenever user click on the column of gridview \"Company name\" then menu or dropdown control will be display.

Data gridview bind the recored with data set.Gird view consist the column "Compnayname" whenever user click on the column of gridview "Company name" then menu or dropdown control will be display.

so how to add dropdown or menu control in gridview. I want to data display in grid view control and user click on company name then Menu will be display which contain the information like Send msg, save company detai开发者_运维技巧l.


You have to make Template Column

 <asp:TemplateField HeaderText="Compnayname">
      <ItemTemplate>
         <asp:DropDownList ID="ddlCompany" runat="server">
         </asp:DropDownList>
      </ItemTemplate>
 </asp:TemplateField>


here isthe complete GRIDView

<asp:GridView ID="grdList" runat="server"  AutoGenerateColumns="False" OnRowCancelingEdit="grdList_RowCancelingEdit" OnRowEditing="grdList_RowEditing" OnRowUpdating="grdList_RowUpdating" OnPageIndexChanging="grdList_PageIndexChanging"  AllowPaging="true">
                    <Columns>
                        <asp:TemplateField>
                            <HeaderTemplate>
                               <asp:Label SkinID="OneColLabel" ID="lblName" runat="server" HeaderText="Edit" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:LinkButton ID="lnbEdit" runat="server" CommandName="Edit" Text="Edit" />
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:LinkButton ID="lnbUpdate" runat="server" CommandName="Update" Text="Update" />
                                <asp:LinkButton ID="lnbCancel" runat="server" CommandName="Cancel" Text="Cancel" />
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Name">
                            <ItemTemplate>
                                <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>' />
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="drpEditName" runat="server" />
                            </EditItemTemplate>
                        </asp:TemplateField>
    </Columns>
</asp:GridView>

You have to bind Dropdownlist on code behind

0

精彩评论

暂无评论...
验证码 换一张
取 消