vb.net - Retrieve datatable.column value in rpt_RowDataBound sub in asp.net -


based on selected answer in post displaying records grouped month , year in asp.net, have modification work with.

in rpt_rowdatabound sub, instead of using fileinfo object, need use database value ("statusupdate").

if month <> trycast(e.item.dataitem, fileinfo).creationtime.month orelse year <> trycast(e.item.dataitem, fileinfo).creationtime.year 

how can replace "fileinfo" in above code line datarow("statusupdate")

code:

html:

<asp:repeater id="rpt" runat="server" onitemdatabound="rpt_rowdatabound" visible="true">     <itemtemplate>         <table width="100%" runat="server" visible="true" id="headertable">             <tr>                 <td colspan="3" style="color: white;" class="textfont"><asp:label id="headertitle" runat="server"></asp:label></td>             </tr>             <tr>                 <td font-size="smaller" align="center" style="width:10%; background-color: #3a4f63; color: white;">view<br>record</td>                 <td font-size="smaller" align="center" style="width:20%; background-color: #3a4f63; color: white;">managerid</td>                 <td font-size="smaller" style="width:20%; background-color: #3a4f63; color: white;">dbcost</td>                 <td font-size="smaller" style="width:20%; background-color: #3a4f63; color: white;">groupid</td>                 <td font-size="smaller" style="width:20%; background-color: #3a4f63; color: white;">updated</td>                 <td font-size="smaller" style="width:20%; background-color: #3a4f63; color: white;">repid</td>             </tr>         </table>         <table width="100%" border="1">             <tr>                 <td style="width:10%;" align="center"><asp:label id="lblisonum" runat="server"></asp:label>                     <asp:hyperlink id="imgfiletype" imageurl="images/mag.gif" navigateurl='<%# setnavigateurl(eval("recid")) %>' runat="server"></asp:hyperlink>                 </td>                 <td style="width:15%;"><asp:label font-size="smaller" id="lblmid" runat="server" text='<%#eval("managerid") %>'></asp:label></td>                 <td style="width:20%;"><asp:label font-size="smaller" id="lbldba" runat="server" text='<%#eval("dbcost") %>'></asp:label></td>                 <td style="width:20%;"><asp:label font-size="smaller" id="lblgroup" runat="server" text='<%#eval("groupid") %>'></asp:label></td>                 <td style="width:20%;"><asp:label font-size="smaller" id="lblstatus" runat="server" text='<%#eval("statusdate") %>'></asp:label></td>                 <td style="width:20%;"><asp:label font-size="smaller" id="lblsalesrep" runat="server" text='<%#eval("salesrepid") %>'></asp:label></td>             </tr>         </table>     </itemtemplate> </asp:repeater> 

code behind:

protected sub rpt_rowdatabound(byval sender object, byval e repeateritemeventargs)      if e.item.itemtype = listitemtype.item orelse e.item.itemtype = listitemtype.alternatingitem         if month <> trycast(e.item.dataitem, fileinfo).creationtime.month orelse year <> trycast(e.item.dataitem, fileinfo).creationtime.year             month = trycast(e.item.dataitem, fileinfo).creationtime.month             year = trycast(e.item.dataitem, fileinfo).creationtime.year             e.item.findcontrol("headertable").visible = true             trycast(e.item.findcontrol("headertitle"), label).text = monthname(trycast(e.item.dataitem, fileinfo).creationtime.month()) & " " & trycast(e.item.dataitem, fileinfo).creationtime.year()         else             e.item.findcontrol("headertable").visible = false         end if     end if end sub 

page_load event:

        dim dt datatable = new datatable()         dim da sqldataadapter = new sqldataadapter(strsql, myconnection)         da.fill(dt)         rpt.datasource = dt         rpt.databind() 

try this:

protected sub rpt_rowdatabound(sender object, e repeateritemeventargs)      if e.item.itemtype = listitemtype.item orelse e.item.itemtype = listitemtype.alternatingitem          if month <> datetime.parse(trycast(e.item.dataitem, datarowview)("statusupdate").tostring()).month orelse year <> datetime.parse(trycast(e.item.dataitem, datarowview)("statusupdate").tostring()).year             month = datetime.parse(trycast(e.item.dataitem, datarowview)("statusupdate").tostring()).month             year = datetime.parse(trycast(e.item.dataitem, datarowview)("statusupdate").tostring()).year             e.item.findcontrol("headertable").visible = true             trycast(e.item.findcontrol("headertitle"), label).text = "files " & datetime.parse(trycast(e.item.dataitem, datarowview)("statusupdate").tostring()).toshortdatestring()         else             e.item.findcontrol("headertable").visible = false         end if     end if end sub 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -