2013-03-12 59 views
1

我有一个GridView,在我的GridView中,我将Linkbuttons添加到某个列。我想要做的是当你点击在我的GridView中创建的LinkBut​​ton时,我想要显示我的ModalPopupExtender。在的RowDataBound创建ModalPopupExtender Gridview

的LinkBut​​ton:

Private Sub grdDetails_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdDetails.RowDataBound 
Try 
    Try 
    If Not iColAttachent Is Nothing Then 
     For Each i In iColAttachent 
     If e.Row.DataItem(i - 1).ToString.Trim.Length > 0 Then 
      Dim c As New TableCell 
      Dim LB As New LinkButton 
      Dim strBookNo As String = e.Row.DataItem(i - 1).ToString 

      ' Create link 
      LB.ID = "LB_" & strBookNo 
      LB.Text = strBookNo.Substring(strBookNo.IndexOf("_") + 1) 
      LB.ToolTip = "Click to change book number" 
      LB.Attributes.Add("AutoPostBack", "False") 
      LB.Attributes.Add("OnClick", "ShowModal()") 
      'HL.Attributes.Add("runat", "server") 

      e.Row.Cells().RemoveAt(i) 
      e.Row.Cells().AddAt(i, c) 
      c.Controls.Add(LB) 
     End If 
     Next 
    End If 
    Catch 
    ' nothing to do 
    End Try 
Catch ex As Exception 

End Try 
End Sub 

JavaScript来显示我的ModalPopupExtender:

<script language="javascript" type="text/javascript"> 
    function ShowModal() { 
     var modal = $find('ModalPopupExtender1'); 
     modal.show(); 
    } 
</script> 

ModalPopupExtender

<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButton1" PopupControlID="Panel1" DropShadow="true" 
      BackgroundCssClass="modalBackground" CancelControlID="cmdCancel" BehaviorID="ModalPopupExtender1" Drag="true"> 

      </asp:ModalPopupExtender> 

的问题是什么,当我点击LinkBut​​ton的我ModalPopupExtender呢显示,但在一秒钟内它再次消失。不知道是否是因为PostBack。

回答

0

通过添加链接按钮并将其分配给modalpopup来解决此问题。也许不是最好的办法,但它的工作原理。