Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Gridview Rowcommand Problem

Gridview Rowcommand Problem

Scheduled Pinned Locked Moved ASP.NET
cssdesignhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    soniasan
    wrote on last edited by
    #1

    In Gridview CaseNo ,HearingDate,To,CC,BCC this data is shown. CaseNo is Primary Key I am having button "SendMail" in that grid view. In gridview Rowcommand Event i write this code if i click on first row send mail command button then Label9.text get First caseno t.e. "LER/111" Simillarly i want To,CC BCC Cell value of that row How i can able to get that Protected Sub MailDetailsGridView_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles MailDetailsGridView.RowCommand ''Code Added For The Send Mail........ If (e.CommandName = "SendMail") Then Label9.Text = e.CommandArgument.ToString() Dim row As GridViewRow row = CType(CType(e.CommandSource, Control).NamingContainer, GridViewRow) Dim email As String = CType(row.Cells(6), DataControlFieldCell).Text If (row.RowType = DataControlRowType.DataRow) Then Dim txtCCMail As TextBox Dim ToMail As String txtCCMail = row.Cells(6).Controls(0).FindControl("ToTextBox") ToMail = txtCCMail.Text End If End If End Sub

    R 2 Replies Last reply
    0
    • S soniasan

      In Gridview CaseNo ,HearingDate,To,CC,BCC this data is shown. CaseNo is Primary Key I am having button "SendMail" in that grid view. In gridview Rowcommand Event i write this code if i click on first row send mail command button then Label9.text get First caseno t.e. "LER/111" Simillarly i want To,CC BCC Cell value of that row How i can able to get that Protected Sub MailDetailsGridView_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles MailDetailsGridView.RowCommand ''Code Added For The Send Mail........ If (e.CommandName = "SendMail") Then Label9.Text = e.CommandArgument.ToString() Dim row As GridViewRow row = CType(CType(e.CommandSource, Control).NamingContainer, GridViewRow) Dim email As String = CType(row.Cells(6), DataControlFieldCell).Text If (row.RowType = DataControlRowType.DataRow) Then Dim txtCCMail As TextBox Dim ToMail As String txtCCMail = row.Cells(6).Controls(0).FindControl("ToTextBox") ToMail = txtCCMail.Text End If End If End Sub

      R Offline
      R Offline
      Rajeesh MP
      wrote on last edited by
      #2

      Hi soniasan TRY this class

      Imports System.Net.Mail
      Imports Microsoft.VisualBasic
      Imports System.Data
      Imports System.Net
      Imports System.Net.Dns
      Imports System.Web.UI.Page
      Imports System.Math
      Imports System.Text.RegularExpressions
      Imports System.Data.SqlClient

      Public Class MailHelper
      ''' ''' Sends an mail message
      '''
      ''' Sender address
      ''' Recepient address
      ''' Bcc recepient
      ''' Cc recepient
      ''' Subject of mail message
      ''' Body of mail message
      Public Sub SendMailMessage(ByVal from As String, ByVal recepient As String, ByVal bcc As String, ByVal cc As String, _
      ByVal subject As String, ByVal body As String)
      ' Instantiate a new instance of MailMessage
      Dim mMailMessage As New MailMessage()

          ' Set the sender address of the mail message
          mMailMessage.From = New MailAddress(from)
          ' Set the recepient address of the mail message
          mMailMessage.To.Add(New MailAddress(recepient))
          ' Check if the bcc value is null or an empty string
          If Not bcc Is Nothing And bcc <> String.Empty Then
              ' Set the Bcc address of the mail message
              mMailMessage.Bcc.Add(New MailAddress(bcc))
          End If
          ' Check if the cc value is null or an empty value
          If Not cc Is Nothing And cc <> String.Empty Then
              ' Set the CC address of the mail message
              mMailMessage.CC.Add(New MailAddress(cc))
          End If
          ' Set the subject of the mail message
          mMailMessage.Subject = subject
          ' Set the body of the mail message
          mMailMessage.Body = body
          ' Secify the format of the body as HTML
          mMailMessage.IsBodyHtml = True
          ' Set the priority of the mail message to normal
          mMailMessage.Priority = MailPriority.Normal
          ' Instantiate a new instance of SmtpClient
          Dim mSmtpClient As New SmtpClient()
      
         
          mSmtpClient.Host = "------"
          mSmtpClient.Port = "---------"
          mSmtpClient.Credentials = New System.Net.NetworkCredential("-----------", "----------")
          ' Send the mail message
          mSmtpClient.Send(mMailMessage)
      End Sub
      

      End Class Use this class

      regards Rajeesh MP

      1 Reply Last reply
      0
      • S soniasan

        In Gridview CaseNo ,HearingDate,To,CC,BCC this data is shown. CaseNo is Primary Key I am having button "SendMail" in that grid view. In gridview Rowcommand Event i write this code if i click on first row send mail command button then Label9.text get First caseno t.e. "LER/111" Simillarly i want To,CC BCC Cell value of that row How i can able to get that Protected Sub MailDetailsGridView_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles MailDetailsGridView.RowCommand ''Code Added For The Send Mail........ If (e.CommandName = "SendMail") Then Label9.Text = e.CommandArgument.ToString() Dim row As GridViewRow row = CType(CType(e.CommandSource, Control).NamingContainer, GridViewRow) Dim email As String = CType(row.Cells(6), DataControlFieldCell).Text If (row.RowType = DataControlRowType.DataRow) Then Dim txtCCMail As TextBox Dim ToMail As String txtCCMail = row.Cells(6).Controls(0).FindControl("ToTextBox") ToMail = txtCCMail.Text End If End If End Sub

        R Offline
        R Offline
        Rajeesh MP
        wrote on last edited by
        #3

        txtCCMail = row.Cells(7).Controls(0).FindControl("ccTextBox") txtBCCMail = row.Cells(9).Controls(0).FindControl("bccTextBox")

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups