Sunday, March 11, 2012

Dropdown extender on a gridview

Try setting it to the ID of a DDL in the EditTemplate for the grid, and put the extender inside the EditTemplate as well. Or the footer row if you are using it for adding new items.


'>'>Ok I have tried this, but still when I edit the item the entire grid is selected. I really dont want to have to press the edit button to get this work instead just hover over to display the dropdown list.

Anymore tips?

thanks again

<asp:GridViewID="grdItems"runat="server"AutoGenerateColumns="False"

AutoGenerateEditButton="True"DataSourceID="SqlDataSource2"

EmptyDataText="There are no data records to display.">

<Columns>

<asp:CommandFieldShowSelectButton="True"/>

<asp:TemplateFieldHeaderText="ItemID"SortExpression="ItemID">

<EditItemTemplate>

<asp:LabelID="Label1"runat="server"Text='<%# Eval("ItemID") %>'></asp:Label>

<ajaxToolkit:DropDownExtenderrunat="server"ID="DDE"

TargetControlID="grdItems"

DropDownControlID="DropPanel"/>

</EditItemTemplate>

<ItemTemplate>

<asp:LabelID="Label1"runat="server"Text='<%# Bind("ItemID") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:BoundFieldDataField="ItemName"HeaderText="ItemName"

SortExpression="ItemName"/>

</Columns>

</asp:GridView>


TargetControlID="grdItems"

You have to add a normal asp:DropDownList first, do all the bindings on that, then add the extender and point it at the DDL, not the grid. Put both inside the edit item template.


Ok finally cracked it :)

<ItemTemplate>
<asp:LabelID="lblProposalNameIdNumber"runat="server"Width="220"CssClass="menulabel">
<%#DataBinder.Eval(Container.DataItem,"RoomID")%>
</asp:Label>
<cc1:DropDownExtenderID="ddeProposalOptions"runat="server"TargetControlID="lblProposalNameIdNumber"DropDownControlID="DropPanel">
</cc1:DropDownExtender>
<asp:PanelID="DropPanel"runat="server">
<asp:LinkButtonID="LinkButton1"runat="server">Edit</asp:LinkButton><br/>
<asp:LinkButtonID="LinkButton2"runat="server">Delete</asp:LinkButton><br/>
<asp:LinkButtonID="LinkButton3"runat="server">Select</asp:LinkButton><br/>
<asp:LinkButtonID="LinkButton4"runat="server">Add Photo(s)</asp:LinkButton><br/>
</asp:Panel>
</ItemTemplate>

This now brings me to my next question.....is it at all possible instead of just assigning the extender to the rows column with the label to assign it to the entire row so when a user hovers over and field within the row the extender is displayed?

Thanks again for all your help


No, sorry. One control to one extender.

No comments:

Post a Comment