TextBox1 is in your
ItemTemplate, You need to find the
TextBox to get it's value.
Replace your loop with this:
foreach (GridViewRow GVRow in GridView1.Rows)
{
Member_ID = GVRow.Cells[0].Text;
TextBox1 = ((TextBox)GVRow.FindControl("TextBox1")).Text;
SqlConnection myConnection = new SqlConnection("user id=sa;" +
"password=prodip@km;server=PRODIP;" +
"Trusted_Connection=yes;" +
"database=Member;");
myConnection.Open();
SqlCommand myCommand = new SqlCommand("INSERT INTO [Collectionamt ] (Member_ID,collectionamt,collectiondate)" +
"Values(@Member_ID,@TextBox1,GETDATE())");
myCommand.Parameters.Add("@Member_ID", System.Data.SqlDbType.Int).Value = Convert.ToInt32(Member_ID);
myCommand.Parameters.Add("@TextBox1", System.Data.SqlDbType.VarChar,50).Value = (TextBox1.ToString());
myCommand.Connection = myConnection;
myCommand.ExecuteNonQuery();
Response.Write("<script language="'javascript'">{alert('" + "Data is Save')}</script>");
myConnection.Close();
}
--Amit