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,038

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


 

[.NET] 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 ไปหน้าถัดไปว่าส่งสำเร็จหรือไม่สำเร็จ

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

01.protected void btnok_Click(object sender, EventArgs e)
02.    {
03.        DateTime date1 =DateTime.Parse( txtdatestart.Text);
04.        DateTime date2 =DateTime.Parse( txtdateEnd.Text);
05.        Quatationinfo info;
06.        ArrayList list = new ArrayList();
07. 
08.        string ConnectString = ConfigurationManager.ConnectionStrings["KHCRMDBSC"].ConnectionString;
09.        SqlConnection conn = new SqlConnection(ConnectString);
10.        string CommandString = "SELECT Companyid,Establisment , DateQuatations FROM Quatations WHERE DateQuatations Between @ParamDate1 AND @ParamDate2";
11.        conn.Open();
12.        SqlCommand comm = new SqlCommand(CommandString, conn);
13.        comm.Parameters.Add("@ParamDate1", SqlDbType.DateTime).Value = date1;
14.        comm.Parameters.Add("@ParamDate2", SqlDbType.DateTime).Value = date2;
15.        SqlDataReader reader = comm.ExecuteReader();
16.        while (reader.Read())
17.        {
18.            info = new Quatationinfo();
19.            info.Companyid = reader.GetString(0);
20.            info.Establishment = reader.GetString(1);
21.            info.DateQuatation = reader.GetDateTime(2);
22.            list.Add(info);
23.        }
24.        conn.Close();
25.        GridView1.DataSource = list;
26.        GridView1.DataBind();




Tag : - - - -

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

 

No. 1



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

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

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

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

GridView & Checkbox (C#)
001.<%@ Page Language="C#" Debug="true" %>
002.<%@ import Namespace="System.Data" %>
003.<%@ import Namespace="System.Data.OleDb" %>
004.<script runat="server">
005. 
006.    OleDbConnection objConn;
007.    OleDbCommand objCmd;
008. 
009.    void Page_Load(object sender,EventArgs e)
010.    {
011.        String strConnString;
012.        strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
013.        Server.MapPath("database/mydatabase.mdb") + ";";
014.        objConn = new OleDbConnection(strConnString);
015.        objConn.Open();
016.         
017.        if(!Page.IsPostBack)
018.        {
019.            BindData();
020.        }
021.    }
022. 
023.    void BindData()
024.    {
025.        String strSQL;
026.        strSQL = "SELECT * FROM customer";
027. 
028.        OleDbDataReader dtReader;
029.        objCmd = new OleDbCommand(strSQL, objConn);
030.        dtReader = objCmd.ExecuteReader();
031.         
032.        //*** BindData to GridView ***//
033.        myGridView.DataSource = dtReader;
034.        myGridView.DataBind();
035. 
036.        dtReader.Close();
037.        dtReader = null;
038. 
039.    }   
040. 
041.    void Page_UnLoad()
042.    {
043.        objConn.Close();
044.        objConn = null;
045.    }
046. 
047.    void myGridView_RowDataBound(Object s, GridViewRowEventArgs e)
048.    {
049.        //*** CustomerID ***//
050.        Label lblCustomerID = (Label)(e.Row.FindControl("lblCustomerID"));
051.        if (lblCustomerID != null)
052.        {
053.            lblCustomerID.Text = (string)DataBinder.Eval(e.Row.DataItem, "CustomerID");
054.        }
055. 
056.        //*** Email ***//
057.        Label lblName = (Label)(e.Row.FindControl("lblName"));
058.        if (lblName != null)
059.        {
060.            lblName.Text = (string)DataBinder.Eval(e.Row.DataItem, "Name");
061.        }
062. 
063.        //*** Name ***//
064.        Label lblEmail = (Label)(e.Row.FindControl("lblEmail"));
065.        if (lblEmail != null)
066.        {
067.            lblEmail.Text = (string)DataBinder.Eval(e.Row.DataItem, "Email");
068.        }
069. 
070.        //*** CountryCode ***//
071.        Label lblCountryCode = (Label)(e.Row.FindControl("lblCountryCode"));
072.        if (lblCountryCode != null)
073.        {
074.            lblCountryCode.Text = (string)DataBinder.Eval(e.Row.DataItem, "CountryCode");
075.        }
076. 
077.        //*** Budget ***//
078.        Label lblBudget = (Label)(e.Row.FindControl("lblBudget"));
079.        if (lblBudget != null)
080.        {
081.            lblBudget.Text = DataBinder.Eval(e.Row.DataItem, "Budget").ToString();
082.        }
083. 
084.        //*** Used ***//
085.        Label lblUsed = (Label)(e.Row.FindControl("lblUsed"));
086.        if (lblUsed != null)
087.        {
088.            lblUsed.Text = DataBinder.Eval(e.Row.DataItem, "Used").ToString();
089.        }
090.    }
091. 
092. 
093.    void Button1_Click(object sender,EventArgs e)
094.    {
095.        CheckBox chkCusID;
096.        Label lblID;
097.        int i;
098.        lblText.Text = "";
099.        for( i = 0; i <= myGridView.Rows.Count - 1; i++)
100.        {
101.            chkCusID = (CheckBox)myGridView.Rows[i].FindControl("chkCustomerID");
102.            lblID = (Label)myGridView.Rows[i].FindControl("lblCustomerID");
103.            if(chkCusID.Checked)
104.            {
105.                //*** Have lblID.Text ***//
106.                this.lblText.Text = this.lblText.Text + "<br>" + lblID.Text;
107.            }
108.        }
109.    }
110. 
111.</script>
112.<html>
113.<head>
114.    <title>ThaiCreate.Com ASP.NET - GridView</title>
115.</head>
116.<body>
117.<form id="form1" runat="server">
118.<asp:GridView id="myGridView" runat="server" AutoGenerateColumns="False" onRowDataBound="myGridView_RowDataBound">
119. 
120.    <Columns>
121. 
122.    <asp:TemplateField HeaderText="Select">
123.        <ItemTemplate>
124.            <asp:CheckBox id="chkCustomerID" runat="server"></asp:CheckBox>
125.        </ItemTemplate>
126.    </asp:TemplateField>
127. 
128.    <asp:TemplateField HeaderText="CustomerID">
129.        <ItemTemplate>
130.            <asp:Label id="lblCustomerID" runat="server"></asp:Label>
131.        </ItemTemplate>
132.    </asp:TemplateField>
133. 
134.    <asp:TemplateField HeaderText="Name">
135.        <ItemTemplate>
136.            <asp:Label id="lblName" runat="server"></asp:Label>
137.        </ItemTemplate>
138.    </asp:TemplateField>
139. 
140.    <asp:TemplateField HeaderText="Email">
141.        <ItemTemplate>
142.            <asp:Label id="lblEmail" runat="server"></asp:Label>
143.        </ItemTemplate>
144.    </asp:TemplateField>
145. 
146.    <asp:TemplateField HeaderText="CountryCode">
147.        <ItemTemplate>
148.            <asp:Label id="lblCountryCode" runat="server"></asp:Label>
149.        </ItemTemplate>
150.    </asp:TemplateField>
151. 
152.    <asp:TemplateField HeaderText="Budget">
153.        <ItemTemplate>
154.            <asp:Label id="lblBudget" runat="server"></asp:Label>
155.        </ItemTemplate>
156.    </asp:TemplateField>
157. 
158.    <asp:TemplateField HeaderText="Used">
159.        <ItemTemplate>
160.            <asp:Label id="lblUsed" runat="server"></asp:Label>
161.        </ItemTemplate>
162.    </asp:TemplateField>
163. 
164.    </Columns>
165.</asp:GridView>
166.<br />
167.<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Submit"></asp:Button>
168.<hr />
169.<asp:Label id="lblText" runat="server"></asp:Label>
170.</form>
171.</body>
172.</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 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





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