  | 
              
	              
	                
  
    |   | 
   
  
    
        
        ต้องการเช็คหัวข้อการประเมิน ที่ถูกเลือกว่าเป็นหัวข้ออะไรอะไร ต้องทำไง     | 
   
  
    |   | 
   
 
 
 
              
  
          
		
     
		
	     
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 คื่อว่ามันติดที่ตรงนามสกุลอะครับ ไม่รู้ว่านามสกุลไร ด้วยปัญญา ผู้รู้ตอบที  
 
 
 
Code (C#) 
protected void btSubmit_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow item in GridView1.Rows)
        {
            if (((RadioButtonList)item.FindControl("rdl")).ตรงนี้มันต้องนามสกุลไรครับ  )    
            {
                decimal score = Convert.ToDecimal(((RadioButtonList)item.FindControl("rdl")).Text);
                string q_id = item.Cells[0].Text;
                // เรียก Method  insert Assessment
                ASSESSMENTTableAdapter ass = new ASSESSMENTTableAdapter();
                
                ass.InsertQuery(Convert.ToInt32(lblass_id.Text), Convert.ToInt32(regis.Text), lblosub_id.Text,q_id,score,txtcomment.Text);
            }
        }
}
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-08-24 19:54:21 | 
                        By :
                            lukawa_small | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 จะทำอะไรครับ                          
               
               | 
             
            
              
			  			  
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-08-24 21:43:35 | 
                        By :
                            webmaster | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ต้องการ บันทึกข้อมูลที่เลือกจาก Radiobuttonlist จาก Gridview  คำถามว่าข้อที่ถูกเลือก ได้คะแนนเท่าไหร่ และเป็นหัวข้ออะไร   
 
แล้วถ้าทำให้มัน วนลูปการทำงาน จบครบทุกข้อครับ แต่ยังคิดการ วนลูปไม่ออก แนะนำหน่อยครับ 
 
Code (C#) 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Web.Configuration;
using DataSet1TableAdapters;
public partial class assessment : System.Web.UI.Page
{
    
    private string sqlquery;
    private SqlConnection con;
    private SqlCommand sqlCom;
    private SqlDataAdapter sqlDA;
    private DataSet ds;
    protected void Page_Load(object sender, EventArgs e)
    {
        ASSESSMENTTableAdapter ass = new ASSESSMENTTableAdapter();
        int count = Convert.ToInt32(ass.Getcount());
        count++;
        lblass_id.Text = "0" + count.ToString().PadLeft(9, '0');
        try
        {
            //ดูว่า login เข้ามาหรือไม่
            if (Session["stu_id"] == null)
            {
                Response.Redirect("login_stu.aspx?");
            }
            //ดูว่าส่งค่ามาหรือไม่
            if (Request.Params["osub_id"] == null )
            {
                Response.Redirect("login_stu.aspx?");
            }
            //ต่อฐานข้อมูล
            con = new SqlConnection(WebConfigurationManager.ConnectionStrings["assassment"].ToString());
            //แสดงค่าที่ส่งมา
            setData(Request.Params["osub_id"]);
            year.Text = Session["year"].ToString();
            term.Text = Session["term"].ToString();
            regis.Text = "100001";
        }
        catch
        {
        }
  
        
    }
    private void setData(string cid)
    {
        con.Open();
        sqlquery = "select t.tea_name as 'name',c.osub_id as 'osid',s.sub_id as 'sid',s.sub_name as 'subject' from OPEN_SUBJECT c ";
        sqlquery += "join TEACHER t on c.tea_id = t.tea_id join SUBJECT s on c.sub_id = s.sub_id ";
        sqlquery += "where c.osub_id = '" + cid + "'";
        sqlDA = new SqlDataAdapter(sqlquery, con);
        ds = new DataSet();
        sqlDA.Fill(ds, "osub");
        con.Close();
        if (ds.Tables["osub"].Rows.Count > 0)
        {
            lblosub_id.Text = ds.Tables["osub"].Rows[0]["osid"].ToString();
            tea_id.Text = ds.Tables["osub"].Rows[0]["name"].ToString();
            sub_id.Text = ds.Tables["osub"].Rows[0]["sid"].ToString();
            sub_name.Text = ds.Tables["osub"].Rows[0]["subject"].ToString();
        }
    }
    protected void btSubmit_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow item in GridView1.Rows)
        {
            if (((RadioButtonList)item.FindControl("rdl")).Text)
            {
                decimal score = Convert.ToDecimal(((RadioButtonList)item.FindControl("rdl")).Text);
                string q_id = item.Cells[0].Text;
                // เรียก Method  insert Assessment
                ASSESSMENTTableAdapter ass = new ASSESSMENTTableAdapter();
                
                ass.InsertQuery(Convert.ToInt32(lblass_id.Text), Convert.ToInt32(regis.Text), lblosub_id.Text,q_id,score,txtcomment.Text);
            }
        }
       
    }
    protected void btCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("home_stu.aspx?");
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
       
        
    }
    protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        
    }
}
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-08-24 22:01:47 | 
                        By :
                            lukawa_small | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ขอบคุณครับที่แนะนำ ได้แล้ว                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-08-26 23:08:45 | 
                        By :
                            lukawa_small | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
      		  
	
     | 
   
 
                 |