New to asp.net and using Visual Studio 2008.
I have a GridView with a column named "Doc" that stores a UNC path for a document. I don't want this column visible, so I set the visible property to "False".
I added a templete field to the GridView with a button that the user will click. I managed to get the Button_click event to fire where I get the value of the "Doc" column for the current row.
However, the Button1_Click subroutine only gets the value of the "Doc" row when the "Doc" column is visible. When I set the "Doc" column visible property to "False" I don't get the UNC path.
Can someone help with this?
Here is the "Doc" field that contains the UNC path.
Here is the templete field with the button.
Here is the code behind for the button click event. The strField1 variable = "" when the "Doc" column visible property is set to false. When the "Doc" column visible property is set to true, then the strField1 variable = "\\*****-***\d$\TrainingDocs\Project Management for Project Team Members_One day.doc"
I have a GridView with a column named "Doc" that stores a UNC path for a document. I don't want this column visible, so I set the visible property to "False".
I added a templete field to the GridView with a button that the user will click. I managed to get the Button_click event to fire where I get the value of the "Doc" column for the current row.
However, the Button1_Click subroutine only gets the value of the "Doc" row when the "Doc" column is visible. When I set the "Doc" column visible property to "False" I don't get the UNC path.
Can someone help with this?
Here is the "Doc" field that contains the UNC path.
Code:
<asp:BoundField DataField="Doc" HeaderText="Doc"
SortExpression="Doc" Visible="False" >
<ControlStyle Font-Size="Smaller" Height="1px" Width="1px" />
<FooterStyle Font-Size="Smaller" Height="1px" Width="1px" />
<HeaderStyle Font-Size="Smaller" Height="1px" BackColor="#80FFFF" Width="1px" />
<ItemStyle Font-Size="Smaller" Height="1px" Width="1px" />
</asp:BoundField>
Here is the templete field with the button.
Code:
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button1" Runat="Server" OnClick="Button1_Click" Text="View Document" />
</ItemTemplate>
<ControlStyle Font-Size="Smaller" />
<HeaderStyle BackColor="#80FFFF" />
<ItemStyle Font-Size="Smaller" />
</asp:TemplateField>
Here is the code behind for the button click event. The strField1 variable = "" when the "Doc" column visible property is set to false. When the "Doc" column visible property is set to true, then the strField1 variable = "\\*****-***\d$\TrainingDocs\Project Management for Project Team Members_One day.doc"
Code:
Protected Sub Button1_Click(ByVal o As Object, ByVal e As EventArgs)
Dim Button1 As Button = DirectCast(o, Button)
Dim grdRow As GridViewRow = DirectCast(Button1.Parent.Parent, GridViewRow)
Dim strField1 As String = grdRow.Cells(0).Text
End Sub