Hello! I am a little bit confused with how to access a specific HyperlinkColumn in my data grid. I loop through each item in my datagrid items, but cannot seem to figure out the appropiatesyntax to reach this bound column. I need to get to it from the behind code because I will modify certain properties from there.
'************ behind code sample *******************
For Each ite In Datagrid1.Items
'this is how i find and modify my controls in the template column in the data
'grid without a problem
imgbutton = CType(ite.FindControl("imgbutSurvDelete"), ImageButton)
imgbutton.Visible = True
'this is how i am trying to find the hyperlikcolumn in the datagrid.
'what i mean by ite.Controls(2) is the second childcontrol (or bound column)
'within the datagrid, but it doesn't work b/c it is not at same hierarchy level
'as HyperLinkColumn).
If arrOptionName(x) = "View" Then
hyplinkcolumn = CType(ite.Controls(2), HyperLinkColumn)
Next
'************** web form code sample *******************
<asp:datagrid id="griGenSurvey" BorderWidth="0" HeaderStyle-VerticalAlign="Top" Width="900px" cellpadding="2" cellspacing="0" runat="server" AutoGenerateColumns="False" AlternatingItemStyle-BackColor="#cccccc" ItemStyle-VerticalAlign="Top" HeaderStyle-HorizontalAlign="Center">
<Columns>
<asp:BoundColumn DataField="SurveyID" HeaderText="#" HeaderStyle-CssClass="000000Text12Bold" ItemStyle-CssClass="000000Text11Bold"></asp:BoundColumn>
<asp:BoundColumn DataField="SurveyName" HeaderText="Name" HeaderStyle-CssClass="000000Text12Bold" ItemStyle-CssClass="000000Text11Normal"></asp:BoundColumn>
<!-- I assume this is (2) in data grid chil;d control index -->
<asp:HyperinkColumn DataField="SurveyTitle" HeaderText="Title" HeaderStyle-CssClass="000000Text12Bold" ItemStyle-CssClass="000000Text11Normal"></asp:HyperlinkColumn>
<asp:TemplateColumn HeaderText="Controls" ItemStyle-Width="85" HeaderStyle-CssClass="000000Text12Bold" ItemStyle-CssClass="000000Text11Normal">
<ItemTemplate>
</asp:hyperlink>
<asp:ImageButton id="imgbutSurvDelete" ImageUrl="../../images/icon_trashcan.gif" runat="server" CommandName="DeleteEvent" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "SurveyID") %>' OnCommand="imgbutSurvDelete_Command" Visible="False">
</asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
**************************************************
Any help would be appreciated.
Thank you!
-ricardo 8~)
'************ behind code sample *******************
For Each ite In Datagrid1.Items
'this is how i find and modify my controls in the template column in the data
'grid without a problem
imgbutton = CType(ite.FindControl("imgbutSurvDelete"), ImageButton)
imgbutton.Visible = True
'this is how i am trying to find the hyperlikcolumn in the datagrid.
'what i mean by ite.Controls(2) is the second childcontrol (or bound column)
'within the datagrid, but it doesn't work b/c it is not at same hierarchy level
'as HyperLinkColumn).
If arrOptionName(x) = "View" Then
hyplinkcolumn = CType(ite.Controls(2), HyperLinkColumn)
Next
'************** web form code sample *******************
<asp:datagrid id="griGenSurvey" BorderWidth="0" HeaderStyle-VerticalAlign="Top" Width="900px" cellpadding="2" cellspacing="0" runat="server" AutoGenerateColumns="False" AlternatingItemStyle-BackColor="#cccccc" ItemStyle-VerticalAlign="Top" HeaderStyle-HorizontalAlign="Center">
<Columns>
<asp:BoundColumn DataField="SurveyID" HeaderText="#" HeaderStyle-CssClass="000000Text12Bold" ItemStyle-CssClass="000000Text11Bold"></asp:BoundColumn>
<asp:BoundColumn DataField="SurveyName" HeaderText="Name" HeaderStyle-CssClass="000000Text12Bold" ItemStyle-CssClass="000000Text11Normal"></asp:BoundColumn>
<!-- I assume this is (2) in data grid chil;d control index -->
<asp:HyperinkColumn DataField="SurveyTitle" HeaderText="Title" HeaderStyle-CssClass="000000Text12Bold" ItemStyle-CssClass="000000Text11Normal"></asp:HyperlinkColumn>
<asp:TemplateColumn HeaderText="Controls" ItemStyle-Width="85" HeaderStyle-CssClass="000000Text12Bold" ItemStyle-CssClass="000000Text11Normal">
<ItemTemplate>
</asp:hyperlink>
<asp:ImageButton id="imgbutSurvDelete" ImageUrl="../../images/icon_trashcan.gif" runat="server" CommandName="DeleteEvent" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "SurveyID") %>' OnCommand="imgbutSurvDelete_Command" Visible="False">
</asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
**************************************************
Any help would be appreciated.
Thank you!
-ricardo 8~)