Get data from DataList cell?

NapstrPSX

Member
Joined
Jan 7, 2010
Messages
5
Programming Experience
1-3
I have a datalist, named: dlstScannedDocuments.

The DataKeyField is FileName, and I am able to retrieve it by using:

dlstScannedDocuments.DataKeys(e.Item.ItemIndex)

The template for the datalist looks like this:

VB.NET:
<ItemTemplate>
                            <table border="0" cellspacing="0" width="100%" id="tblScannedDocuments" cellpadding="0">
                                <tr>
                                    <td width="25%" align="left">
                                        <asp:LinkButton ID="Linkbutton3" runat="server" Text="View">
                                        </asp:LinkButton>
                                    </td>
                                    <td width="25%%" colspan="1" align="left">
                                        <%#Container.DataItem("LobDocumentType")%>
                                    </td>
                                    <td width="25%" align="center" colspan="1">
                                        <%#String.Format("{0:d}", Container.DataItem("LobDateReceived"))%>
                                    </td>
                                    <td width="25%" align="center" colspan="1">
                                        <%#String.Format("{0:d}", Container.DataItem("LobScanDate"))%>
                                    </td>
                                    <td width="25%%" colspan="1" align="left" style="display:none">
                                        <%#Container.DataItem("LobReportYear")%>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>

How can I retrieve what is in the LobReportYear cell for a record? For the life of me I cannot figure out how to do it anywhere. Any help very much appreciated, thank you.
 
Once you get the table (HtmlTable) you can get the innertext of the particular cell (HtmlTableCell) by indexing. e.g.
VB.NET:
Dim Years As New Genric.List(of String)
For Each row As HtmlTableRow In table.Rows
    Years.Add(CType(row.Controls(4), HtmlTableCell).InnerText)
Next

However i suggest that you put all that in a Label control for easier referencing. ;)
 
I have tried using a label control but I don't know how to do it. I haven't seen good code in vb.net to help.

I also don't really know what you're talking about in this reply... could you or someone else please break it down a bit more? it is all stored in HTML tables.
 
I was not trying to be rude, I am just ignorant. For instance I don't know what you are referring to when you say:

Once you get the table (HtmlTable)
 
Back
Top