Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,028

HOME > .NET Framework > Forum > CheckBox กับ Gridview พี่ๆค่ะ หนูต้องการนำcheck box ให้มาอยู่ใน Gridview สำหรับเพื่อส่งเมลล์ไปหาลูกค้า



 

CheckBox กับ Gridview พี่ๆค่ะ หนูต้องการนำcheck box ให้มาอยู่ใน Gridview สำหรับเพื่อส่งเมลล์ไปหาลูกค้า

 



Topic : 031313



โพสกระทู้ ( 3 )
บทความ ( 0 )



สถานะออฟไลน์




พี่ๆค่ะ หนูต้องการนำcheck box ให้มาอยู่ใน Gridview สำหรับเพื่อส่งเมลล์ไปหาลูกค้า

โดยหลักการคือ
1.เรียกชื่อลูกค้าจากฐานข้อมูลในดาต้าเบสให้มาโชว์ในGridview โดยในกรณีนี้จะได้ชื่อลูกค้าที่แต่ละคนมาโชว์
2.เมื่อโชว์แล้วก็ต้องการให้มีcheck box ที่Gridview เพิ่มมาอีกหนึ่งคอลัมภ์ หลังชื่อลูกค้าของแต่ละบรรทัดเพื่อที่จะสามารถเลือกได้ว่าจะส่งอีเมลล์ให้กับลูกค้าคนไหนได้บ้าง โดยในกรณีนี้คือ จะมีอีเมล์ฉบับเดียวแต่ส่งหั้ยกับลูกค้าที่กดCheckbox
3.เมื่อกดเช็คที่ Checkbox ที่เลือกลูกค้าแล้วก็กดปุ่มด้านล่างใต้Gridview คือปุ่ม send เพื่อส่งอีเมล์ให้แก่ลูกค้าที่เลือกทุกคน
4. เมื่อกดป่มก้อให้reponse ไปหน้าถัดไปว่าส่งสำเร็จหรือไม่สำเร็จ

********จบแล้วค่ะ ช่วยหน่อยนะค่ะ หนูจนปัญญาจริงๆ*******

protected void btnok_Click(object sender, EventArgs e)
    {
        DateTime date1 =DateTime.Parse( txtdatestart.Text);
        DateTime date2 =DateTime.Parse( txtdateEnd.Text);
        Quatationinfo info;
        ArrayList list = new ArrayList();

        string ConnectString = ConfigurationManager.ConnectionStrings["KHCRMDBSC"].ConnectionString;
        SqlConnection conn = new SqlConnection(ConnectString);
        string CommandString = "SELECT Companyid,Establisment , DateQuatations FROM Quatations WHERE DateQuatations Between @ParamDate1 AND @ParamDate2";
        conn.Open();
        SqlCommand comm = new SqlCommand(CommandString, conn);
        comm.Parameters.Add("@ParamDate1", SqlDbType.DateTime).Value = date1;
        comm.Parameters.Add("@ParamDate2", SqlDbType.DateTime).Value = date2;
        SqlDataReader reader = comm.ExecuteReader();
        while (reader.Read())
        {
            info = new Quatationinfo();
            info.Companyid = reader.GetString(0);
            info.Establishment = reader.GetString(1);
            info.DateQuatation = reader.GetDateTime(2);
            list.Add(info);
        }
        conn.Close();
        GridView1.DataSource = list;
        GridView1.DataBind();




Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-09-04 19:36:58 By : kanumchan View : 6439 Reply : 5
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ผมมีแต่ Code ที่ใช้ Select Checkbox จาก GridView น่ะครับ

GridView & Checkbox (C#)
<%@ Page Language="C#" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">

	OleDbConnection objConn;
	OleDbCommand objCmd;

    void Page_Load(object sender,EventArgs e)
	{
		String strConnString;
		strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + 
		Server.MapPath("database/mydatabase.mdb") + ";";
		objConn = new OleDbConnection(strConnString);
		objConn.Open();
		
		if(!Page.IsPostBack)
		{
			BindData();
		}
    }

	void BindData()
	{
		String strSQL;
		strSQL = "SELECT * FROM customer";

		OleDbDataReader dtReader;
		objCmd = new OleDbCommand(strSQL, objConn);
		dtReader = objCmd.ExecuteReader();
		
		//*** BindData to GridView ***//
		myGridView.DataSource = dtReader;
		myGridView.DataBind();

		dtReader.Close();
		dtReader = null;

	}    

	void Page_UnLoad()
	{
		objConn.Close();
		objConn = null;
	}

	void myGridView_RowDataBound(Object s, GridViewRowEventArgs e) 
	{
		//*** CustomerID ***//
		Label lblCustomerID = (Label)(e.Row.FindControl("lblCustomerID"));
		if (lblCustomerID != null)
		{
			lblCustomerID.Text = (string)DataBinder.Eval(e.Row.DataItem, "CustomerID");
		}

		//*** Email ***//
		Label lblName = (Label)(e.Row.FindControl("lblName"));
		if (lblName != null)
		{
			lblName.Text = (string)DataBinder.Eval(e.Row.DataItem, "Name");
		}

		//*** Name ***//
		Label lblEmail = (Label)(e.Row.FindControl("lblEmail"));
		if (lblEmail != null)
		{
			lblEmail.Text = (string)DataBinder.Eval(e.Row.DataItem, "Email");
		}

		//*** CountryCode ***//
		Label lblCountryCode = (Label)(e.Row.FindControl("lblCountryCode"));
		if (lblCountryCode != null)
		{
			lblCountryCode.Text = (string)DataBinder.Eval(e.Row.DataItem, "CountryCode");
		}

		//*** Budget ***//
		Label lblBudget = (Label)(e.Row.FindControl("lblBudget"));
		if (lblBudget != null)
		{
			lblBudget.Text = DataBinder.Eval(e.Row.DataItem, "Budget").ToString();
		}

		//*** Used ***//
		Label lblUsed = (Label)(e.Row.FindControl("lblUsed"));
		if (lblUsed != null)
		{
			lblUsed.Text = DataBinder.Eval(e.Row.DataItem, "Used").ToString();
		}
	}


    void Button1_Click(object sender,EventArgs e)
	{
        CheckBox chkCusID;
        Label lblID;
        int i;
        lblText.Text = "";
        for( i = 0; i <= myGridView.Rows.Count - 1; i++)
		{
            chkCusID = (CheckBox)myGridView.Rows[i].FindControl("chkCustomerID");
            lblID = (Label)myGridView.Rows[i].FindControl("lblCustomerID");
            if(chkCusID.Checked)
			{
                //*** Have lblID.Text ***//
                this.lblText.Text = this.lblText.Text + "<br>" + lblID.Text;
            }
        }
    }

</script>
<html>
<head>
    <title>ThaiCreate.Com ASP.NET - GridView</title>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView id="myGridView" runat="server" AutoGenerateColumns="False" onRowDataBound="myGridView_RowDataBound">

	<Columns>

	<asp:TemplateField HeaderText="Select">
		<ItemTemplate>
			<asp:CheckBox id="chkCustomerID" runat="server"></asp:CheckBox>
		</ItemTemplate>
	</asp:TemplateField>

	<asp:TemplateField HeaderText="CustomerID">
		<ItemTemplate>
			<asp:Label id="lblCustomerID" runat="server"></asp:Label>
		</ItemTemplate>
	</asp:TemplateField>

	<asp:TemplateField HeaderText="Name">
		<ItemTemplate>
			<asp:Label id="lblName" runat="server"></asp:Label>
		</ItemTemplate>
	</asp:TemplateField>

	<asp:TemplateField HeaderText="Email">
		<ItemTemplate>
			<asp:Label id="lblEmail" runat="server"></asp:Label>
		</ItemTemplate>
	</asp:TemplateField>

	<asp:TemplateField HeaderText="CountryCode">
		<ItemTemplate>
			<asp:Label id="lblCountryCode" runat="server"></asp:Label>
		</ItemTemplate>
	</asp:TemplateField>

	<asp:TemplateField HeaderText="Budget">
		<ItemTemplate>
			<asp:Label id="lblBudget" runat="server"></asp:Label>
		</ItemTemplate>
	</asp:TemplateField>

	<asp:TemplateField HeaderText="Used">
		<ItemTemplate>
			<asp:Label id="lblUsed" runat="server"></asp:Label>
		</ItemTemplate>
	</asp:TemplateField>

	</Columns>
</asp:GridView>
<br />
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Submit"></asp:Button>
<hr />
<asp:Label id="lblText" runat="server"></asp:Label>
</form>
</body>
</html>



Ref : (C#) ASP.NET GridView Control - FindControl






Date : 2009-09-04 21:17:06 By : webmaster
 


 

No. 2

Guest


ของหนูทำแล้วค่ะแต่ม่าทรายทำไมเมื่อเช็คที่check box เมื่อรันแล้วได้ค่า false ยังงัยช่วยหน่อยนะค่ะ

ขอบคุณมากค่ะ
Date : 2009-09-06 13:29:25 By : kanumchan
 

 

No. 3



โพสกระทู้ ( 3 )
บทความ ( 0 )



สถานะออฟไลน์


คุณวินค่ะหนูทำแล้วแต่ม่าได้อ่าค่ะ ยังงัยรบกวนอีกครั้งนะค่ะ เพราะว่าเมื่อเช็คบล็อกแล้วได้ค่าfalseค่ะ

ขอบคุณนะค่ะ
Date : 2009-09-06 15:13:01 By : kanumchan
 


 

No. 4



โพสกระทู้ ( 6 )
บทความ ( 0 )



สถานะออฟไลน์


ลองดูก่อนนะครับเพราะทำตอนนี้ยังไม่ได้เลยเดียวหาตัวบักก่อน
Date : 2009-09-08 11:13:34 By : weeraoneman
 


 

No. 5

Guest


พี่คับช่วยหน่อยนะคับ ผมต้องการที่จะ บันทึกข้อมูลลงฐานข้อมูล โดยเลือกจาก Checkbox ที่อยู่ใน GridView โดยเอา ID ของ ข้อมูลบันทึกลงฐานอะคับ ขอความช่วยเหลือด้วยคับ ชาว IT
Date : 2010-01-15 00:56:53 By : bkflp
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : CheckBox กับ Gridview พี่ๆค่ะ หนูต้องการนำcheck box ให้มาอยู่ใน Gridview สำหรับเพื่อส่งเมลล์ไปหาลูกค้า
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่