Dear Friends,
As working with GridView object in ASP.Net 3.5, i was facing a problem.
I have a gridview with some hidden column, here is my gridview structure:
<asp:boundfield visible=”False” datafield=”ID” />
<asp:boundfield datafield=”DOCNAME” headertext=”Name”>
<itemstyle horizontalalign=”Left”>
</asp:boundfield>
<asp:boundfield datafield=”VersionNumber” headertext=”Version”>
<itemstyle horizontalalign=”Center”>
</asp:boundfield>
<asp:boundfield visible=”False” datafield=”PDFFileName”>
<itemstyle horizontalalign=”Left”>
</asp:boundfield>
<asp:boundfield datafield=”intSequenceNumber” headertext=”Active”/>
<asp:checkboxfield datafield=”blnActive” headertext=”Active” />
As you can see I have Id and PDFFileName column hidden.
Now if i select some files and on postback i need those selected files and their Ids, i am getting blanks values for all the hidden cells.
This is how i was doing it:
Dim strIds As String = String.Empty
Dim strFiles As String = String.Empty
For Each drRow As GridViewRow In Me.gvHiddenColumn.Rows
strIds = strIds + drRow.Cells(pvt_GridColumn.ID).Text + “,”
strFiles = strFiles + drRow.Cells(pvt_GridColumn.PDFFileName).Text + “,”
Next
but i am getting ids and files balnks.
A simple solution for this problem is make the column hidden in the grid row bound event or after that, so i did it in prerender and it worked fine.
Private Sub GridViewHiddenColumn_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
Me.gvColumns.Columns(pvt_GridColumn.ID).Visible = False
Me.gvColumns.Columns(pvt_GridColumn.PDFFileName).Visible = False
End Sub
Happy Programming,
Thanks,
Ashish
No Comments Yet so far
Leave a comment
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>