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.