Does anyone know why when you create a control(Link Button)in the SelectedItemTemplate of a datalist it become a Literal Control. I am trying to do a FindControl() on the controls in the SelectedItem but it wont find them, i populate a list of all the controls id and they show up blank(they do show up), I also add the type of the control and they are Literals but all the controls created in the ItemTemplate show/act normal.
Heres the code if that helps:
The code behind:
Heres the code if that helps:
Code:
<SelectedItemTemplate> ID:
<%# DataBinder.Eval(Container.DataItem,"ID") %>
<br>
<br>
Description:
<%# DataBinder.Eval(Container.DataItem,"DocumentDescription") %>
<br>
<br>
Details:
<%# DataBinder.Eval(Container.DataItem,"Details") %>
<br>
<br>
FileType:
<%# DataBinder.Eval(Container.DataItem,"FileType") %>
<br>
<br>
Difficulty:
<%# DataBinder.Eval(Container.DataItem,"DiffDescription") %>
<br>
<br>
<asp:HyperLink ID="hlView1" Runat="server" Target="_blank" NavigateUrl="default.aspx" Enabled="True">View</asp:HyperLink>
|
<asp:LinkButton ID="btndetails1" Runat="server" text="Show Details" CommandName="select" Enabled="False"></asp:LinkButton>
|
<asp:LinkButton ID="btnComment1" Runat="server" text="Comment"></asp:LinkButton>
</SelectedItemTemplate>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,"DocumentDescription") %>
<asp:Image ID=diff ImageUrl='<%# DataBinder.Eval(Container.DataItem,"Image") %>' Runat=server ImageAlign=Right>
</asp:Image>
<BR>
<asp:HyperLink ID="hlView2" Runat="server" Target="_blank" NavigateUrl="default.aspx" Enabled="True">View</asp:HyperLink>
|
<asp:LinkButton ID="btnDetails2" Runat="server" text="Show Details" CommandName="select"></asp:LinkButton>
|
<asp:LinkButton ID="btnComment2" Runat="server" text="Comment"></asp:LinkButton>
</ItemTemplate>
Code:
private void dlDocumentList_ItemDataBound(object sender, DataListItemEventArgs e)
{
int fNum = 0;
fileType fType;
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
HyperLink hl= (HyperLink)e.Item.FindControl("hlView2");
fNum = (int)dsDocumentList1.Tables[0].Rows[e.Item.ItemIndex]["ID"];
fType = (fileType)dsDocumentList1.Tables[0].Rows[e.Item.ItemIndex]["FileTypeNum"];
hl.NavigateUrl = GetUrl(fNum,fType);
}
if (e.Item.ItemType == ListItemType.SelectedItem)
{
HyperLink hl= (HyperLink)e.Item.FindControl("hlView1");
fNum = (int)dsDocumentList1.Tables[0].Rows[e.Item.ItemIndex]["ID"];
fType = (fileType)dsDocumentList1.Tables[0].Rows[e.Item.ItemIndex]["FileTypeNum"];
hl.NavigateUrl = GetUrl(fNum,fType);
}
}