1
사용자가 GridView에 표시된 데이터를 전자 메일로 보내는 GridView가있는 ASP.Net 웹 양식에 명령 단추가 있습니다.ASP.Net 명령 단추를 보이지 않게하거나 코드 숨김 코드로 숨김
이 GridView는 사용자가 이미지 단추를 클릭 할 때 일시적으로 GridView에서 제거하고 전자 메일을 보낼 때 단추가 다시 나타나도록하려는 "선택"명령 단추입니다.
이메일에 포함되지 않기를 바라는 이메일에 표시되기 때문에 버튼을 제거하고 싶습니다.
단추없이 GridView를 새로 고치는 코드 숨김 파일에서 코딩하는 방법을 알려주시겠습니까? 여기
버튼을 보여주는 몇 가지 마크 업입니다 :Protected Sub ImageButtonEmailThisList_Click(sender As Object, e As ImageClickEventArgs)
' Get the rendered HTML.
'-----------------------
Dim SB As New StringBuilder()
Dim SW As New StringWriter(SB)
Dim htmlTW As New HtmlTextWriter(SW)
' Remove the select button for a short while.
'--------------------------------------------
GridViewSummary.RenderControl(htmlTW)
' Get the HTML into a string.
' This will be used in the body of the email report.
'---------------------------------------------------
Dim dataGridHTML As String = SB.ToString()
Dim SmtpServer As New SmtpClient()
ObjMailMessage = New MailMessage()
Try
With ObjMailMessage
.To.Add(New MailAddress(TextBoxEmailRecipient.Text))
.Subject = "Knowledge Academy Teacher's Schdule"
.Body = dataGridHTML
.IsBodyHtml = True
.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
End With
SmtpServer.Send(ObjMailMessage)
LabelEmailMessage.Text = "<i>Email sent to " & TextBoxEmailRecipient.Text & "!</i>"
ImageButtonEmailThisList.Visible = True
Catch ex As Exception
MsgBox(ex.ToString())
Finally
' Refresh the GridView with select button back in place.
'-------------------------------------------------------
End Try
End Sub
우리가 원하는 곳에 주석 섹션을 보여
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Button
ID="ButtonSelect"
runat="server"
CausesValidation="False"
CommandName="Select"
Text="Select Schedule Item Details" />
</ItemTemplate>
이것은 우리가 그것을 사용하는 코딩이의 GridView의 이메일을 보낸다 단추를 숨기고 다시 표시하는 코드를 추가하십시오.
완벽! 그러한 빠르고 유용한 답장을 보내 주셔서 감사합니다. :-) –
방금 했어요. 나는 그것을하기 전에 노력했지만 우리는 대답을 받아 들일 수있는 시간을 얼마나 빨리 제한 할 것 같습니다. 나는 당신에게 1 표 이상을 줄 수 있었으면 좋겠다. 그러나 그것은 또한 제한 될 것으로 보인다. 너무 빨리 도와 줘서 고마워. :-) –
그건 그렇고. 단추의 "색인"값 대신 단추의 실제 ID를 사용할 수 있습니까? –