This obviously does not work but how do I accomplish this. It's one of the template fields in a web data grid. I want to show a drop down with actions (and images eventually too)
<ig:TemplateDataField Header-Text="Actions" Key="AssetID" Width="75"> <ItemTemplate> <ig:WebDropDown ID='ddCustomList' runat='server' Width='75'> <Items> <ig:DropDownItem Text="Edit" NavigateUrl='AssetEdit.aspx?aid=<%# Eval("AssetID")%>&wid=<%# Eval("WorkCenterID")%>'></ig:DropDownItem> <ig:DropDownItem Text="Transfer" NavigateUrl='AssetTransferInitiate.aspx?aid=<%# Eval("AssetID")%>&wid=<%# Eval("WorkCenterID")%>'></ig:DropDownItem> <ig:DropDownItem Text="Documents" NavigateUrl='AssetDocuments.aspx?aid=<%# Eval("AssetID")%>&wid=<%# Eval("WorkCenterID")%>'></ig:DropDownItem> </Items> </ig:WebDropDown> </ItemTemplate> <Header Text="Actions" /></ig:TemplateDataField>
Can anyone help? Basically when I choose an item it ends up with the url exactly as you se ethere instead of putting my AssetID and my WorkCenterID in it's place. Help?
Hello Irri,
You can also use the InitializeRow event for the purpose.
Let's assume that the AssetID is contained in the first column and the WorkCenterID is in the second column.
You should add only the WebDropDown inside the ItemTemplate without any items in it.
You can add the items after finding the control inside the InitializeRow event of the WebDataGrid.
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4
<ig:TemplateDataField Key="Template1" Width="220px">
<ItemTemplate>
<ig:WebDropDown ID="WebDropDown1" runat="server" Width="200px" DropDownContainerMaxHeight="180px"
EnableAnimations="False" EnableDropDownAsChild="true">
</ig:WebDropDown>
</ItemTemplate>
</ig:TemplateDataField>
protected void WebDataGrid1_InitializeRow(object sender, RowEventArgs e)
{
WebDropDown wdd = (WebDropDown)e.Row.Items[4].FindControl("WebDropDown1");
DropDownItem item = new DropDownItem();
item.Text = "Edit";
item.NavigateUrl = @"AssetEdit.aspx? aid =" + e.Row.Items[0].Value + "&wid=" + e.Row.Items[1].Value;
wdd.Items.Add(item);
item = new DropDownItem();
item.Text ="Transfer";
item.NavigateUrl = @"AssetTransferInitiate.aspx?aid=" + e.Row.Items[0].Value + "&wid=" + e.Row.Items[1].Value;
item.Text ="Documents";
item.NavigateUrl = @"AssetDocuments.aspx?aid=" + e.Row.Items[0].Value + "&wid=" + e.Row.Items[1].Value;
}
Let me know if you need further assistance.
Hello,
I am just checking about the progress of this issue.
Let me know if you need any further assistance.
Databinding expressions are only supported on objects that have a DataBinding event.
Infragistics.Web.UI.ListControls.DropDownItem does not have a DataBinding event.
I recommend you to use the build in DropDownProvider for the purpose and Item template in order to set the Navigate URL.
Below there is code snippet demonstrating this.
I am using the standard Northwin
// The databound column
<ig:BoundDataField DataFieldName="CategoryID" Key="CategoryID">
<Header Text="CategoryID" />
</ig:BoundDataField>
…….
// The DropDownProvider
<EditorProviders>
<ig:DropDownProvider ID="WebDataGrid1_DropDownProvider1">
<EditorControl runat="server" DropDownContainerMaxHeight="200px" EnableAnimations="False"
EnableDropDownAsChild="False" DataSourceID="SqlDataSource2"
TextField="CategoryName" ValueField="CategoryID">
<asp:HyperLink ID="HyperLink1" runat="server"
Text='<%# Eval("CategoryName")%>'
NavigateUrl='<%#"http://www.google.bg/search?q="+Eval("CategoryName")%>'>
</asp:HyperLink>
</EditorControl>
</ig:DropDownProvider>
</EditorProviders>
………
// The column setting matching the column and the editor
<ig:EditingCore>
<Behaviors>
<ig:CellEditing>
<ColumnSettings>
<ig:EditingColumnSetting ColumnKey="CategoryID" EditorID="WebDataGrid1_DropDownProvider1" />
</ColumnSettings>
</ig:CellEditing>
</Behaviors>
</ig:EditingCore>
Let me know if you need further assistance regarding this.