日期:2011-02-09  浏览次数:20463 次

其实很简单,只要将这一类的东东都放到    <EditItemTemplate>里就行了
    <EditItemTemplate>
                            <asp:DropDownList ID="cmbCategories" Runat="server"></asp:DropDownList>
                        </EditItemTemplate>

就可以在CS中操作它了,填充数据,等等等等


<asp:datagrid id="dgProducts" runat="server" AutoGenerateColumns="False" DataKeyField="ProductID" CellPadding="4" BorderWidth="1px" BorderColor="#DEDFDE" BackColor="White" BorderStyle="None" GridLines="Vertical" ForeColor="Black">
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#CE5D5A"></SelectedItemStyle>
                <AlternatingItemStyle BorderStyle="Double" BorderColor="#0000C0" BackColor="White"></AlternatingItemStyle>
                <ItemStyle CssClass="header" BackColor="#F7F7DE"></ItemStyle>
                <HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#6B696B"></HeaderStyle>
                <FooterStyle BackColor="#CCCC99"></FooterStyle>
                <Columns>
                    <asp:BoundColumn DataField="ProductName" HeaderText="Name"></asp:BoundColumn>
                    <asp:TemplateColumn HeaderText="Category">
                        <ItemTemplate>
                            <%# Container.DataItem("CategoryName")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropDownList ID="cmbCategories" Runat="server"></asp:DropDownList>
                        </EditItemTemplate>
                    </asp:TemplateColumn>
                    <asp:EditCommandColumn ButtonType="PushButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
                </Columns>
            </asp:da