Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
I have created a Dynamic linkbutton at run time in girdview that shows Group total using Row_Created event of Gridview and i want to get Click event of this linkbutton.when we click this linkbutton a method called
 
Protected Sub GrdAllDist_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GrdAllDist.RowCreated
 

       Dim IsSubTotalRowNeedToAdd As Boolean = False
 
       If (strPreviousRowID <> String.Empty) AndAlso (DataBinder.Eval(e.Row.DataItem, "DistCode") IsNot Nothing) Then
           If strPreviousRowID <> DataBinder.Eval(e.Row.DataItem, "DistCode").ToString() Then
               IsSubTotalRowNeedToAdd = True
           End If
       End If
 
       If (strPreviousRowID <> String.Empty) AndAlso (DataBinder.Eval(e.Row.DataItem, "DistCode") Is Nothing) Then
           IsSubTotalRowNeedToAdd = True
           intSubTotalIndex = 0
       End If
 
       If IsSubTotalRowNeedToAdd Then
           Dim grdViewProducts As GridView = DirectCast(sender, GridView)
 
           Creating a Row
           Dim SubTotalRow As New GridViewRow(0, 0, DataControlRowType.DataRow, DataControlRowState.Insert)
 
           HeaderCell = New TableCell()
          Dim TotalRec_sub_link As New LinkButton()
         TotalRec_sub_link.Text = String.Format("{0}", TotalRec_sub)
          HeaderCell.Controls.Add(TotalRec_sub_link)
         HeaderCell.HorizontalAlign = HorizontalAlign.Center
           SubTotalRow.Cells.Add(HeaderCell)
End If
 End Sub
this is the method
 
Private Sub TotalRec_sub_link_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Try
 
            status = "ALL"
            Dim DtSubList As DataTable
            Dim objcrl As New Circle()
 
            Dim gvRow As GridViewRow = CType(CType(sender, Control).Parent.Parent, GridViewRow)
            Dim index As Integer = gvRow.RowIndex
 
            hfdistSubID = gvRow.FindControl("SubtotHiddnDistID")
 
            distSubID = CType(hfdistSubID.Value, Integer)
            If deptsubID <> 0 And distSubID <> 0 Then
                DtSubList = objcrl.ListSubAllDistDeprtRpt(deptsubID, status, distSubID, CType(Session("fdt"), String), CType(Session("tdt"), String))
                dvSub = New DataView(DtSubList, "", "DistName,DeptName", DataViewRowState.CurrentRows)
                ViewState("DtSubList") = dvSub.ToTable()
                GrdSubGrid.Visible = True
                GrdSubGrid.DataSource = dvSub
                GrdSubGrid.DataBind()
                Session("reporSubtList") = dvSub.ToTable()
                GrdAllDist.DataSource = CType(Session("reportList"), DataTable)
                GrdAllDist.DataBind()
            End If
        Catch ex As Exception
 
        End Try
 
    End Sub
Please Help me and Thanks in advance.
Posted 6-Feb-13 20:16pm
Edited 6-Feb-13 20:20pm
4.8K
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 403
1 Sergey Alexandrovich Kryukov 227
2 Richard Deeming 180
3 ChauhanAjay 170
4 Snehasish_Nandy 161
0 Sergey Alexandrovich Kryukov 6,367
1 OriginalGriff 5,588
2 CPallini 2,473
3 Richard MacCutchan 1,627
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web02 | 2.8.140821.2 | Last Updated 7 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100