注意Page.GetPostBackClientHyperlink(button, "")Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load btnDelete.Attributes.Add("onclick", "javascript:return confirm('Are you sure you want to delete this record?');") If Not IsPostBack Then Dim gp As New M_GPDetails(CStr(Session("username")), CStr(Session("pwd"))) dgGP.DataSource = gp.SelectAll() dgGP.DataKeyField = "ADM0100" dgGP.DataBind() If Not Request("id") Is Nothing Then panDetails.Visible = True LoadData(CInt(Request("id"))) End If End If End Sub Private Sub LoadData(ByVal id As Int32) Dim gp As New M_GPDetails(CStr(Session("username")), CStr(Session("pwd"))) With gp .Init(id) tbFname.Text = .sADM0101 tbLname.Text = .sADM0102 tbPnum.Text = .sADM0104 tbMCN.Text = .sADM0105 tbAddress.Text = .sADM0106 tbSuburb.Text = .sADM0107 tbPostcode.Text = .sADM0108 tbPhone.Text = .sADM0109 tbPhone2.Text = .sADM0111 tbMobile.Text = .sADM0110 tbFax.Text = .sADM0112 tbEmail.Text = .sADM0113 ddlGP.SelectedValue = CStr(.sADM0103) ddlType.SelectedValue = CStr(.sADM0114) End With End SubPrivate Sub dgGP_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgGP.ItemDataBound If e.Item.ItemIndex <> -1 Then e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='DCF4F8'") e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white'") Dim button As LinkButton = CType(e.Item.Cells(0).Controls(0), LinkButton) e.Item.Attributes.Add("onclick", Page.GetPostBackClientHyperlink(button, "")) End If End Sub
EditTitle.Text = textRow["title"].ToString();
EditSurporter.Text = textRow["surporter"].ToString();
EditPhone.Text = textRow["phone"].ToString();
EditPowerPhone.Text = textRow["powerPhone"].ToString();
EditEmail.Text = textRow["email"].ToString();
EditOrderNumber.Text = textRow["orderNum"].ToString();这么来写,Edit开头的都是TextBox
MS_POSITIONING="GridLayout"><FONT face="ËÎÌå"></FONT><br>
<asp:datagrid id="dgGP" style="Z-INDEX: 101; LEFT: 0px; POSITION: absolute; TOP: 0px" runat="server"
Width="100%" CellPadding="1" AutoGenerateColumns="False" BackColor="#5D6972" BorderWidth="1px"
Font-Size="12px" BorderStyle="None" BorderColor="MidnightBlue">
<SelectedItemStyle Font-Bold="True" ForeColor="#663399" BackColor="#FFCC66"></SelectedItemStyle>
<AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>
<ItemStyle ForeColor="MidnightBlue" CssClass="dg_hover" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" Height="25px" ForeColor="White"></HeaderStyle>
<FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle>
<Columns>
<asp:ButtonColumn Text="Select" CommandName="Select">
<ItemStyle ForeColor="Red"></ItemStyle>
</asp:ButtonColumn>
<asp:TemplateColumn HeaderText="Name">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ADM0101") & " " & DataBinder.Eval(Container, "DataItem.ADM0102") %>' ID="Label1" NAME="Label1">
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Type">
<ItemTemplate>
<%#GetDoctorType( DataBinder.Eval(Container, "DataItem.ADM0114")) %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="ADM0104" HeaderText="Provider Number"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Title">
<ItemTemplate>
<%#GetTitle( DataBinder.Eval(Container, "DataItem.ADM0103")) %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="ADM0105" HeaderText="Medical Centre Name "></asp:BoundColumn>
<asp:BoundColumn DataField="ADM0109" HeaderText="Phone"></asp:BoundColumn>
</Columns>
</asp:datagrid></DIV><asp:panel id="panDetails" runat="server" width="100%" Height="150px" Visible="False">
<TABLE cellSpacing="0" cellPadding="2" width="100%" border="0">
<TR>
<TD class="font_title2" align="center">Other Doctor Details
</TD>
</TR>
<TR>
<TD height="20"></TD>
</TR>
</TABLE>
<DIV class="updown4">
<TABLE cellSpacing="0" cellPadding="2" width="100%" border="0">
<TR class="font1" height="25">
<TD align="center" width="15%">First Name</TD>
<TD width="18%">
<asp:TextBox id="tbFname" runat="server" Width="100%"></asp:TextBox></TD>
<TD align="center" width="15%">Last Name</TD>
<TD width="18%">
<asp:TextBox id="tbLname" runat="server" Width="100%"></asp:TextBox></TD>
<TD noWrap align="center" width="15%">Provider Number</TD>
<TD width="19%">
<asp:TextBox id="tbPnum" runat="server" Width="100%"></asp:TextBox></TD>
</TR>
<TR class="font1">
<TD noWrap align="center" width="15%">Type</TD>
<TD>
<asp:DropDownList id="ddlType" runat="server" CssClass="ddl">
<asp:ListItem Value="1">GP</asp:ListItem>
<asp:ListItem Value="2" Selected="True">VMO</asp:ListItem>
<asp:ListItem Value="3">Other</asp:ListItem>
</asp:DropDownList></TD>
<TD noWrap align="center" width="15%">Title</TD>
<TD>
<asp:DropDownList id="ddlGP" runat="server" CssClass="ddl">
<asp:ListItem Value="1">Dr</asp:ListItem>
<asp:ListItem Value="2" Selected="True">Professor</asp:ListItem>
<asp:ListItem Value="3">A/Professor</asp:ListItem>
</asp:DropDownList></TD>
<TD noWrap align="center" width="15%"></TD>
<TD width="19%"></TD>
</TR>
<TR>
<TD noWrap align="center" colSpan="4"> Medical Centre Name
<asp:TextBox id="tbMCN" runat="server" Width="293px"></asp:TextBox></TD>
</TR>
<TR class="font1" height="25">
<TD style="HEIGHT: 30px" align="center" width="15%"> Address</TD>
<TD style="HEIGHT: 30px" width="30%" colSpan="2">
<asp:TextBox id="tbAddress" runat="server" Width="100%"></asp:TextBox></TD>
<TD style="HEIGHT: 30px" align="center"> Suburb</TD>
<TD style="HEIGHT: 30px" width="15%" colSpan="2">
<asp:TextBox id="tbSuburb" runat="server" Width="100%"></asp:TextBox></TD>
</TR>
<TR class="font1">
<TD align="center">Postcode</TD>
<TD id="Td1" runat="server">
<asp:TextBox id="tbPostcode" runat="server" Width="100%"></asp:TextBox></TD>
<TD align="center">Fax</TD>
<TD>
<asp:TextBox id="tbFax" runat="server" Width="100%"></asp:TextBox></TD>
<TD noWrap align="center" width="15%">Email</TD>
<TD width="15%">
<asp:TextBox id="tbEmail" runat="server" Width="100%"></asp:TextBox></TD>
</TR>
<TR class="font1" height="25">
<TD align="center" width="15%">Phone</TD>
<TD width="15%">
<asp:TextBox id="tbPhone" runat="server" Width="100%"></asp:TextBox></TD>
<TD noWrap align="center" width="15%">Afterhour Phone</TD>
<TD width="15%">
<asp:TextBox id="tbPhone2" runat="server" Width="100%"></asp:TextBox></TD>
<TD noWrap align="center" width="15%">Mobile</TD>
<TD width="15%">
<asp:TextBox id="tbMobile" runat="server" Width="100%"></asp:TextBox></TD>
</TR>
<TR height="25">
<TD></TD>
<TD></TD>
<TD align="left">
<asp:Button id="btnSave" runat="server" CssClass="button1" Text="Save"></asp:Button></TD>
<TD align="right">
<asp:Button id="btnDelete" runat="server" CssClass="button1" Text="Delete"></asp:Button></TD>
<TD></TD>
<TD></TD>
</TR>
</TABLE>
</DIV>
</asp:panel>
注意Page.GetPostBackClientHyperlink(button, "")Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
btnDelete.Attributes.Add("onclick", "javascript:return confirm('Are you sure you want to delete this record?');")
If Not IsPostBack Then
Dim gp As New M_GPDetails(CStr(Session("username")), CStr(Session("pwd")))
dgGP.DataSource = gp.SelectAll()
dgGP.DataKeyField = "ADM0100"
dgGP.DataBind()
If Not Request("id") Is Nothing Then
panDetails.Visible = True
LoadData(CInt(Request("id")))
End If
End If
End Sub
Private Sub LoadData(ByVal id As Int32)
Dim gp As New M_GPDetails(CStr(Session("username")), CStr(Session("pwd")))
With gp
.Init(id)
tbFname.Text = .sADM0101
tbLname.Text = .sADM0102
tbPnum.Text = .sADM0104
tbMCN.Text = .sADM0105
tbAddress.Text = .sADM0106
tbSuburb.Text = .sADM0107
tbPostcode.Text = .sADM0108
tbPhone.Text = .sADM0109
tbPhone2.Text = .sADM0111
tbMobile.Text = .sADM0110
tbFax.Text = .sADM0112
tbEmail.Text = .sADM0113
ddlGP.SelectedValue = CStr(.sADM0103)
ddlType.SelectedValue = CStr(.sADM0114)
End With
End SubPrivate Sub dgGP_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgGP.ItemDataBound
If e.Item.ItemIndex <> -1 Then e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='DCF4F8'")
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white'")
Dim button As LinkButton = CType(e.Item.Cells(0).Controls(0), LinkButton)
e.Item.Attributes.Add("onclick", Page.GetPostBackClientHyperlink(button, ""))
End If
End Sub
==========================================
怎么可能,那些代码都经过测试的,看看你的事件委托是不是丢了。
if(!Page.IsPostBack)
{}
的外面