I have an .aspx that opens an .ascx when a button is pressed.
The .asx has a gridview with a button to select a row. When the row is
selected the .asx closes automatically and the event onrowcommand is not
fired.
Why is this?
This is the button in the .aspx
Protected Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
ctlLookUp = CType(Page.LoadControl("Controls\UserLookUp.ascx"),
System.Web.UI.Control)
pnlUser.Controls.Add(ctlLookUp)
pnlUser.Visible = True
TxtSampler.Text = strSampler
End Sub
This is the event in the .ascx
Protected Overridable Sub ViewRow_RowCommand(ByVal sender As Object, ByVal
e
As GridViewCommandEventArgs) Handles GridLIMS.RowCommand
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim selectedRow As GridViewRow = GridLIMS.Rows(index)
Dim contactCell As TableCell = selectedRow.Cells(1)
Dim contact As String = contactCell.Text
strSampler = contact
End Sub
This is the html in the .ascx
<asp:GridView ID="GridLIMS" runat="server" EnableViewState=true
OnRowCommand="View_RowCommand" AutoGenerateColumns="False" >
<FooterStyle BackColor="White" ForeColor="#000066" />
<RowStyle ForeColor="Black" BorderStyle="Solid" />
<PagerStyle BackColor="White" ForeColor="#000066"
HorizontalAlign="Left" />
<HeaderStyle BackColor="#006699" Font-Bold="True"
ForeColor="White" />
<Columns>
<asp:CommandField ButtonType="Button" ShowSelectButton="True"
SelectText="Select" />
</Columns>
</asp:GridView>