GridView.SelectedIndexChanged事件中没有任何功能 [英] No function in GridView.SelectedIndexChanged Event
本文介绍了GridView.SelectedIndexChanged事件中没有任何功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我点击网格视图中特定行的选择时,它应显示面板供我回复反馈。但是没有行动。
When I click on the select for a particular row in grid view it should display the panel for me to reply the feedback. But there is no action.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Net;
using System.Net.Mail;
namespace PS
{
public partial class AdminHome : System.Web.UI.Page
{
public SqlConnection cn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Bala\MyStuffs\system\PS\PS\App_Data\Database1.mdf;Integrated Security=True;User Instance=True");
protected void Page_Load(object sender, EventArgs e)
{
}
protected void GridView1_SelectedIndexChanged(object sender, System.EventArgs e)
{
GridViewRow row = GridView1.SelectedRow;
lblFeedbackNo.Text = row.Cells[1].Text;
txtComment.Text = row.Cells[2].Text;
Panel1.Visible = true;
GridView1.Visible = false;
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
string aTo = null;
string aFrom = "ps_fyp@outlook.com";
string aSubject = "WPEHMS Reply Message";
string aMsg = "Dear Student," + Environment.NewLine + txtReply.Text + Environment.NewLine + Environment.NewLine + Environment.NewLine + "Regards, " + Environment.NewLine + "WPEHMS";
if (string.IsNullOrEmpty(txtReply.Text)) {
lblValidation.Visible = true;
} else {
//------------------------------------------------------ Get email from database -------------------------------------------------------
SqlCommand cmd = new SqlCommand("SELECT fdk_Email From tblFeedback Where fdk_No ='" + lblFeedbackNo.Text + "'",cn);
cn.Open();
aTo=(string)cmd.ExecuteScalar();
cn.Close();
//------------------------------------------------- Email service (hotmail) -------------------------------------------------------------
string mMailServer = "smtp.live.com";
//this is the name of mail server that email is sent to
int mPort = 587;
//port of mail server "use a value of 0 if none need be specified
MailMessage message = new MailMessage();
message.From = new MailAddress(aFrom);
message.Subject = aSubject;
message.Body = aMsg;
message.To.Add(aTo);
message.IsBodyHtml = false;
message.Priority = MailPriority.Normal;
SmtpClient oSMTP = new SmtpClient(mMailServer, mPort);
// creates instance of mail client
var _with1 = oSMTP;
_with1.EnableSsl = true;
_with1.DeliveryMethod = SmtpDeliveryMethod.Network;
_with1.Credentials = new NetworkCredential("ps_fyp@outlook.com", "Thepassword");
try {
oSMTP.Send(message);
} catch (Exception ex) {
System.Windows.Forms.MessageBox.Show(ex.Message);
}
//
//------------------------------------------------ Store replied data into database -----------------------------------------------------
//string theStatus = "Replied";
SqlCommand cmd1 = new SqlCommand("UPDATE tblFeedback " + "SET staff_ID = '" + Session["idcode"] + "', fdk_Reply= '" + txtReply.Text + "' WHERE fdk_No = '" + lblFeedbackNo.Text + "'",cn);
cn.Open();
cmd1.ExecuteNonQuery();
cn.Close();
System.Windows.Forms.MessageBox.Show("Reply Sent Successful");
Panel1.Visible = false;
GridView1.DataBind();
GridView1.Visible = true;
}
}
}
}
推荐答案
首先表示在aspx grideview控件和grideviews autopostpack = true中添加了事件'GridView1_SelectedIndexChanged'。有一段时间我想念这只认为事件不会发生。
first comform that the event 'GridView1_SelectedIndexChanged' is added in the aspx grideview control and the grideviews autopostpack = true . some time i miss this thinks only the event can't fire.
这篇关于GridView.SelectedIndexChanged事件中没有任何功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文