问题描述
您好..
当用户点击gridview内的按钮时,我想获得行命令的值。
gridview是一个模态弹出窗口,模态弹出窗口在tab容器中,tab容器在master页面内。
问题是gridview_rowcommand没有被触发。
我尝试了另一种调用按钮点击事件的方法。但也没有任何反应。
这里是按钮点击的代码。按钮点击事件由15个其他按钮共享,因此我没有放''句柄button.click''
Hello..
I want to get value of row command when user click a button inside gridview.
The gridview is in a modal popup, the modal popup is in tab container and the tab container is inside master page.
The problem is gridview_rowcommand not fired.
I''ve tried another method which calls button click event. But nothing happens too.
Here''s the code for button click. The button click event is shared by 15 other buttons so that I didnt put ''handles button.click''
Protected Sub btn_Click(sender As Object, e As EventArgs)
ModalPopupExtender1.PopupControlID = "PanelShowMC"
ModalPopupExtender1.TargetControlID = "PanelShowMC"
ModalPopupExtender1.Show()
' MsgBox("FIRED!")
Dim mainContent As ContentPlaceHolder = DirectCast(Me.Master.FindControl("MainContent"), ContentPlaceHolder)
Dim tabCon As AjaxControlToolkit.TabContainer = DirectCast(mainContent.FindControl("TabContainer1"), AjaxControlToolkit.TabContainer)
Dim tabPan As AjaxControlToolkit.TabPanel = DirectCast(tabCon.FindControl("TabPanel1"), AjaxControlToolkit.TabPanel)
Dim gridv As GridView = DirectCast(tabPan.FindControl("gdShowArea"), GridView)
Dim aaa As AsyncPostBackTrigger = New AsyncPostBackTrigger
aaa.ControlID = gridv.UniqueID
aaa.EventName = "gdShowArea_RowCommand"
Dim btn As Button = sender
MsgBox(btn.ID)
End Sub
HTML:
HTML:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server" >
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0"
Width ="1250px" Height="2000px"
CssClass="Tab" >
<cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="Machine Layout">
<HeaderTemplate> Machine Layout </HeaderTemplate>
<ContentTemplate>
<pre><cc1:ModalPopupExtender ID="panelShow_ModalPopupExtender" runat="server"
BackgroundCssClass="ModalPopupBG" OkControlID="btnClose"
PopupControlID="panelShow" TargetControlID="panelShow"
DynamicServicePath="" Enabled="True">
</cc1:ModalPopupExtender>
<asp:Panel ID="panelShow0" runat="server" BackColor="White"
BorderColor="#009900" BorderStyle="Solid" CssClass="ModalWindow" Height="600px"
Width="654px">
<br />
<asp:DropDownList ID="ddlArea" runat="server">
</asp:DropDownList>
<asp:Button ID="btnViewKIV" runat="server" CssClass="buttonMC" Text="View" />
<br />
<asp:GridView ID="gdShowArea" runat="server" AutoGenerateColumns="False"
BorderStyle="None" Height="500px" OnRowDataBound="gdShowArea_RowDataBound"
ShowHeader="False" Width="96px">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<center>
<asp:Button ID="btnC1" runat="server" CausesValidation="False"
CommandArgument="<%# Container.DataItemIndex + 1%>"
CommandName="ViewC1"
CssClass="btnmcdynamic" Font-Size="X-Small" Width="40px" />
</center>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<center>
<asp:Button ID="btnC2" runat="server" CommandName="ViewC1"
CssClass="btnmcdynamic" Font-Size="X-Small" Width="40px" />
</center>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<br />
<center>
</center>
</asp:Panel>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
</asp:Content>
gdShowArea_rowcommand:
gdShowArea_rowcommand:
Private Sub gdShowArea_RowCommand(sender As Object, e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gdShowArea.RowCommand
Dim i As Integer = CType(e.CommandArgument, Integer)
Dim area As String = Me.ddlArea.SelectedItem.Text
Dim col As String = btn.ID.Substring(3, 2)
Dim row As String = "R" & i
Dim loccode As String = String.Concat(area, col, row)
End Sub
推荐答案
<asp:button id="btn" runat="server" xmlns:asp="#unknown">
onClientClick = "
这篇关于内部模态弹出窗口中的GridView rowcommand未触发。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!