asp.net - Merging gridview cells with templatefields -
i'm trying format gridview during onrowdatabound event need merge column cells values. works find except 1 of columns templatefield linkbutton inside. code reads blanks when iterates through templatefield column , merges entire column single cell.
markup:
<asp:gridview id="grdsummary" runat="server" onrowdatabound="grdsummary_rowdatabound" > <columns> <asp:templatefield headertext="period" > <itemtemplate> <asp:linkbutton id="lnkperiod" runat="server" cssclass="linkbuttoncellstyle" text='<%# eval("period") %>' onclick="lnkquartersummary_click" commandargument='<%# bind("period") %>' /> </itemtemplate> </asp:templatefield> <asp:boundfield headertext="timeline" datafield="timeline" /> <asp:boundfield headertext="americas" datafield="americas" dataformatstring="{0:#,0}" itemstyle-cssclass="summarygridcellstyle" /> </columns> </asp:gridview>
codebehind:
protected sub grdsummary_rowdatabound(byval sender object, byval e gridviewroweventargs) rowindex integer = grdsummary.rows.count - 2 0 step -1 dim grdrow gridviewrow = grdsummary.rows(rowindex) dim grdpreviousrow gridviewrow = grdsummary.rows(rowindex + 1) cellcount integer = 0 0 if grdrow.cells(cellcount).text = grdpreviousrow.cells(cellcount).text if grdpreviousrow.cells(cellcount).rowspan < 2 grdrow.cells(cellcount).rowspan = 2 else grdrow.cells(cellcount).rowspan = grdpreviousrow.cells(cellcount).rowspan + 1 end if grdpreviousrow.cells(cellcount).visible = false end if next cellcount next rowindex end sub
i'm able read templatefield value using this:
dim test string = databinder.eval(e.row.dataitem, "period")
but can read current row, not previous 1 well. ideas?
asp.net vb.net gridview
No comments:
Post a Comment