2011-09-17 14 views
0

経由のGridView内の値を選択GET:は、RadioButtonListの私はこのコードを持っていますforeach

if (e.CommandName == "Comment") 
{ 
    SqlConnection scn = new SqlConnection(ClsPublic.GetConnectionString()); 
    SqlCommand scm = new SqlCommand("UPDATE tblImages SET fComment = @fComment WHERE ([email protected])", scn); 

    string mytext = ""; 
    foreach (GridViewRow row in GVPictures.Rows) 
    { 
     mytext = ((RadioButtonList)row.FindControl("RBComment")).SelectedItem.Text; 
    } 
    scm.Parameters.AddWithValue("@fComment", mytext); 
    scm.Parameters.AddWithValue("@fId", e.CommandArgument); 
    scn.Open(); 
    scm.ExecuteNonQuery(); 
    scn.Close(); 
} 

しかし、このコードは、最後の行ではなく、私の選択した行の値を返します。私に何ができる? 選択した行の値を取得するにはどうすればよいですか?

答えて

0

'((RadioButtonList)e.SelectedRow.FindControl( "RBComment"))。SelectedValue.Text; OR ((RadioButtonList)e.Row.FindControl( "RBComment"))。SelectedValue.Text; '

+0

e? in rowcommand eは他のメソッドを返します。 –

関連する問題