问题描述
<asp:GridViewclass="datatable"ID="GridViewAfd"runat="server"AllowSorting="True"AutoGenerateDeleteButton="True"AutoGenerateEditButton="True"AllowPaging="True"EnableViewState="False"EnableTheming="False"AutoGenerateColumns="False">
这是GridView,我想用的是btnSave.Attributes.Add(“onclick”,”Javascript:returnconfirm(‘Areyousuretosave?’);”)这样的方法来弄,但是我找不到按键的对象名(例如btnSave),楼下贴出前台和后台的全部代码
解决方案
解决方案二:
前台代码:<%@Controllanguage="vb"debug="true"Inherits="Modules.SLZKernDataBeheer.View"CodeFile="View.ascx.vb"AutoEventWireup="false"Explicit="True"%><%@RegisterTagPrefix="dnn"Namespace="DotNetNuke.UI.WebControls"Assembly="DotNetNuke.WebControls"%><asp:LabelID="debuglbl"runat="server"text=""/><asp:PanelID="Panel1"runat="server"style="display:none;position:absolute;border:1pxsolidgray;border-left:#DDDDDD;border-top:#DDDDDD;background:#EEEEEE;width:270px;height:70px;padding:6px;left:288px;top:8px;"><asp:Labelrunat="server"ID="PanelLbl"Text="Kies"></asp:Label><br/><asp:DropDownListID="PanelList"runat="server"style="width:260px"EnableViewState="False"></asp:DropDownList><br/><asp:HiddenFieldID="PanelKey"runat="server"/><asp:HiddenFieldID="DelRelatieKey"runat="server"/><asp:HiddenFieldID="DelRelatieTable"runat="server"/><asp:LinkButtonID="BtnAdd"runat="server"Text="Add"></asp:LinkButton> <ahref="#"onclick="toggle($('<%=Panel1.ClientID%>'))">Cancel</a></asp:Panel><strong>Gegevens:</strong><asp:DropDownListrunat="server"ID="DataSelector"AutoPostBack="True"EnableViewState="False"><asp:ListItem>Vakgroepen</asp:ListItem><asp:ListItem>Afdelingen</asp:ListItem><asp:ListItem>Deelsites</asp:ListItem><asp:ListItem>Specialisten</asp:ListItem><asp:ListItem>Wachttijden</asp:ListItem><asp:ListItem>Spreekuren</asp:ListItem><asp:ListItem>Contactgegevens</asp:ListItem><asp:ListItem>Zoektrefwoorden</asp:ListItem><asp:ListItem>Links</asp:ListItem><asp:ListItem>Linkgroepen</asp:ListItem></asp:DropDownList><%IfDataSelector.Text="Spreekuren"Then%><br/>Vakgroep:<asp:DropDownListrunat="server"ID="Vakgroep"AutoPostBack="True"></asp:DropDownList> <asp:ButtonID="btnExportPDF"runat="server"Text="PDF"/><br/>Afdeling:<asp:DropDownListrunat="server"ID="Afdeling"AutoPostBack="True"/><br/><asp:LabelID="lblAfdeling"runat="server"></asp:Label><asp:GridViewclass="datatable"ID="GridViewEdit"runat="server"AllowSorting="False"AutoGenerateDeleteButton="False"AutoGenerateEditButton="False"AllowPaging="True"EnableViewState="False"EnableTheming="False"AutoGenerateColumns="False"ShowFooter="False"><Columns><asp:TemplateFieldHeaderText="Specialist"><ItemTemplate><asp:LabelID="Spe"runat="server"><%#Eval("Specialist")%></asp:Label><asp:HiddenFieldID="HSpe"runat="server"Value='<%#Eval("Specialist")%>'/></ItemTemplate><FooterTemplate><asp:DropDownListrunat="server"ID="FootSpecialist"AutoPostBack="true"class="footSpecialist"DataTextField="Achternaam"DataValueField="ID"DataSource='<%#BindSpecialistData%>'></asp:DropDownList></FooterTemplate></asp:TemplateField><asp:TemplateFieldHeaderText="Ma"><ItemTemplate><asp:DropDownListrunat="server"ID="Ma"AutoPostBack="true"><asp:ListItemText=""Value=""/><asp:ListItemText="o"Value="o"/><asp:ListItemText="m"Value="m"/><asp:ListItemText="om"Value="om"/></asp:DropDownList><asp:HiddenFieldID="HW1"runat="server"Value='<%#Eval("w1")%>'/></ItemTemplate><FooterTemplate><asp:DropDownListrunat="server"ID="FootMa"AutoPostBack="true"><asp:ListItemText=""Value=""/><asp:ListItemText="o"Value="o"/><asp:ListItemText="m"Value="m"/><asp:ListItemText="om"Value="om"/></asp:DropDownList></FooterTemplate></asp:TemplateField><asp:TemplateFieldHeaderText="Di"><ItemTemplate><asp:DropDownListrunat="server"ID="Di"AutoPostBack="true"><asp:ListItemText=""Value=""/><asp:ListItemText="o"Value="o"/><asp:ListItemText="m"Value="m"/><asp:ListItemText="om"Value="om"/></asp:DropDownList><asp:HiddenFieldID="HW2"runat="server"Value='<%#Eval("w2")%>'/></ItemTemplate><FooterTemplate><asp:DropDownListrunat="server"ID="FootDi"AutoPostBack="true"><asp:ListItemText=""Value=""/><asp:ListItemText="o"Value="o"/><asp:ListItemText="m"Value="m"/><asp:ListItemText="om"Value="om"/></asp:DropDownList></FooterTemplate></asp:TemplateField><asp:TemplateFieldHeaderText="Wo"><ItemTemplate><asp:DropDownListrunat="server"ID="Wo"AutoPostBack="true"><asp:ListItemText=""Value=""/><asp:ListItemText="o"Value="o"/><asp:ListItemText="m"Value="m"/><asp:ListItemText="om"Value="om"/></asp:DropDownList><asp:HiddenFieldID="HW3"runat="server"Value='<%#Eval("w3")%>'/></ItemTemplate><FooterTemplate><asp:DropDownListrunat="server"ID="FootWo"AutoPostBack="true"><asp:ListItemText=""Value=""/><asp:ListItemText="o"Value="o"/><asp:ListItemText="m"Value="m"/><asp:ListItemText="om"Value="om"/></asp:DropDownList></FooterTemplate></asp:TemplateField><asp:TemplateFieldHeaderText="Do"><ItemTemplate><asp:DropDownListrunat="server"ID="Doo"AutoPostBack="true"><asp:ListItemText=""Value=""/><asp:ListItemText="o"Value="o"/><asp:ListItemText="m"Value="m"/><asp:ListItemText="om"Value="om"/></asp:DropDownList><asp:HiddenFieldID="HW4"runat="server"Value='<%#Eval("w4")%>'/></ItemTemplate><FooterTemplate><asp:DropDownListrunat="server"ID="FootDoo"AutoPostBack="true"><asp:ListItemText=""Value=""/><asp:ListItemText="o"Value="o"/><asp:ListItemText="m"Value="m"/><asp:ListItemText="om"Value="om"/></asp:DropDownList></FooterTemplate></asp:TemplateField><asp:TemplateFieldHeaderText="Vr"><ItemTemplate><asp:DropDownListrunat="server"ID="Vr"AutoPostBack="true"><asp:ListItemText=""Value=""/><asp:ListItemText="o"Value="o"/><asp:ListItemText="m"Value="m"/><asp:ListItemText="om"Value="om"/></asp:DropDownList><asp:HiddenFieldID="HW5"runat="server"Value='<%#Eval("w5")%>'/></ItemTemplate><FooterTemplate><asp:DropDownListrunat="server"ID="FootVr"AutoPostBack="true"><asp:ListItemText=""Value=""/><asp:ListItemText="o"Value="o"/><asp:ListItemText="m"Value="m"/><asp:ListItemText="om"Value="om"/></asp:DropDownList></FooterTemplate></asp:TemplateField></Columns></asp:GridView><br/><asp:Buttonrunat="server"ID="NieuweBtn"Text="nieuwearts"class="nieuweBtn"/> <asp:Buttonrunat="server"ID="EditBtn"Text="opslaan"class="editBtn"/><%Else%> Scope:<asp:DropDownListrunat="server"ID="VGScope"AutoPostBack="True"EnableViewState="False"></asp:DropDownList><br/><br/>Filter:<asp:TextBoxID="DataFilter"runat="server"AutoPostBack="True"EnableViewState="false"></asp:TextBox><br/><br/><asp:LabelID="lblItemCount"runat="server"></asp:Label><%IfDataSelector.Text="Afdelingen"Then%><asp:GridViewclass="datatable"ID="GridViewAfd"runat="server"AllowSorting="True"AutoGenerateDeleteButton="True"AutoGenerateEditButton="True"AllowPaging="True"EnableViewState="False"EnableTheming="False"AutoGenerateColumns="False"><Columns><asp:BoundFieldDataField="id"HeaderText="id"/><asp:BoundFieldDataField="afdeling"HeaderText="Afdeling"/><asp:CheckBoxFieldDataField="poli?"HeaderText="Poli?"/><asp:TemplateFieldHeaderText="PrimVakGroep"><EditItemTemplate><asp:DropDownListrunat="server"ID="PrimVakGroep"AutoPostBack="false"></asp:DropDownList><asp:HiddenFieldID="DefaultPrim"runat="server"Value='<%#Eval("PrimVakgroep")%>'/></EditItemTemplate><ItemTemplate><asp:Labelrunat="server"ID="PrimText"Text='<%#Eval("PrimVakgroep")%>'></asp:Label><asp:HiddenFieldID="DefaultPrimValue"runat="server"Value='<%#Eval("PrimVakgroep")%>'/></ItemTemplate></asp:TemplateField><asp:BoundFieldDataField=""HeaderText="Vakgroeprelaties"/><asp:BoundFieldDataField=""HeaderText="Spreekuren"/><asp:BoundFieldDataField=""HeaderText="Contactgegevens"/><asp:BoundFieldDataField=""HeaderText="Wachttijden"/><asp:BoundFieldDataField=""HeaderText="Specialisten"/><asp:BoundFieldDataField=""HeaderText="Deelsites"/></Columns></asp:GridView><%else%><asp:GridViewclass="datatable"ID="GridView"runat="server"AllowSorting="True"AutoGenerateDeleteButton="True"AutoGenerateEditButton="True"AllowPaging="True"EnableViewState="False"EnableTheming="False"></asp:GridView><%EndIf%><br/><asp:Buttonrunat="server"ID="AddBtn"Text="Voegeenvakgroeptoe"/><%EndIf%><br/><br/>#itemsperpagina:<asp:TextBoxID="ItemsPerPage"runat="server"AutoPostBack="True"Text="10"Width="30"></asp:TextBox><br/>Preview#relaties:<asp:TextBoxID="RelatiePreview"runat="server"AutoPostBack="True"Text="0"Width="30"></asp:TextBox><br/><br/><%--<asp:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="false"/>--%>
解决方案三:
后台执行删除调用的方法SubDeleteRelation()IfNotDelRelatieKey.Value=""ThenDimcnAsSqlConnection=NewSqlConnection(ConfigurationManager.ConnectionStrings("SLZData").ConnectionString)DimcmdAsSqlCommand=NewSqlCommand("",cn)cmd.CommandText="DELETEFROM"&DelRelatieTable.Value&"WHEREID="&DelRelatieKey.ValueDelRelatieKey.Value=""DelRelatieTable.Value=""cn.Open()cmd.ExecuteNonQuery()cn.Close()GetMetaData()EndIfEndSub
解决方案四:
这个工程是用DNN框架做的,临时安排我做这个项目,我不是学VB的所以对VB的语法和结构不了解,各位大虾帮帮忙哈
解决方案五:
((button)findcontrol("id")).attribute.add("click","returnconfirm('确认删除?');");
解决方案六:
引用4楼flyerwing的回复:
((button)findcontrol("id")).attribute.add("click","returnconfirm('确认删除?');");
大哥能不能详细一点啊,((button)findcontrol("id"))这个是强制转换控件为button?头晕啊……
解决方案七:
引用4楼flyerwing的回复:
((button)findcontrol("id")).attribute.add("click","returnconfirm('确认删除?');");
还是说findcontrol("id")是一个通过控件id找控件的方法?
解决方案八:
别沉啊,有同样想知道的童鞋一起顶起来啊