Follow by Email

Friday, 14 December 2012

Find Control in datagrid in VB.Net

.Aspx Page:

<asp:datagrid id="dgCases" runat="server" Width="100%" CellPadding="4" AutoGenerateColumns="False" DataKeyField="DispatchId" BorderWidth="2" BorderColor="black" AllowSorting="True" BackColor="silver">

<Columns>

<asp:TemplateColumn ItemStyle-Width="1%" ItemStyle-Wrap="False" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<table width="100%" class="gridtems">
<tr>
<td nowrap>

                                                    <asp:HyperLink Runat="server" ID="lnkCaseDetails"  NavigateUrl='<%# GetURLLink(Container.DataItem("DispatchId"),"CaseInfo.aspx?CaseId=")%>'>CaseNo.</asp:HyperLink>

</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateColumn>

</Columns>
</asp:datagrid>


CodeBehind Page:


  If e.Item.ItemType = ListItemType.AlternatingItem OrElse _
e.Item.ItemType = ListItemType.Item Then
  Dim lnkCaseDetails As HyperLink
                    lnkCaseDetails = CType(e.Item.FindControl("lnkCaseDetails"), HyperLink)
                    lnkCaseDetails.Visible = False
                End If

0 comments:

Post a Comment


                                                            

 
Design by Abhinav Ranjan Sinha