Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7806695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:37:01+00:00 2026-06-02T02:37:01+00:00

I have a scenario in my project I have a grid view and submit

  • 0

I have a scenario in my project I have a grid view and submit button which generates dynamic rows and there is an image button Edit which edits those rows and these rows bind with datatable first and when we click on save button all the reflect changes in datatable save in database there is no Update button

Question:

How can I save the previously edited rows into the DataTable and in which event?

Plz help its urgent

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:37:02+00:00Added an answer on June 2, 2026 at 2:37 am

    Declare a datatable, adding columns to it to represent all the data i want to save from the grid to the table in the DB.
    Loop through the rows in the grid, get the data from each cell that you want to save and add it to each column in your datatable.
    Use the datatable to do a bulk insert into the table in the DB.

    
        DataTable dtMealTemplate = new DataTable();
        dtMealTemplate.Columns.Add("MealTemplateID", Type.GetType("System.Int32")); 
        dtMealTemplate.Columns.Add("WeekNumber", Type.GetType("System.Int32")); 
        dtMealTemplate.Columns.Add("DayOfWeek", Type.GetType("System.String")); 
        foreach (GridViewRow gvr in GridView.Rows)
        { 
         drMT = dtMealTemplate.NewRow(); 
         drMT["MealTemplateID"] = gvr.Cells[0].text; 
         drMT["WeekNumber"] = gvr.Cells[1].text; 
         drMT["DayOfWeek"] = gvr.Cells[2].Text; 
         dtMealTemplate.Rows.Add(drMT); 
        } 
    
         public void InsertMealsTemplate(int iMealTemplateID, DataTable dtMealsData) 
         { 
        SqlCommand cmd = new SqlCommand(); 
        SqlDataAdapter sa = new SqlDataAdapter(cmd); 
        SqlCommandBuilder cmb = new SqlCommandBuilder(sa); 
        SqlTransaction oTrans; 
        SqlConnection oConn = new SqlConnection(GetConnectionString()); 
        DataSet ds = new DataSet(); 
        oConn.Open(); 
        cmd = oConn.CreateCommand(); 
        oTrans = oConn.BeginTransaction(); 
        cmd.Connection = oConn; 
        cmd.Transaction = oTrans; 
        cmd.CommandType = CommandType.Text; 
        cmd.CommandText = "SELECT * FROM YOURTABLENAME WHERE 1 = 1 ";
        sa = new SqlDataAdapter(cmd); 
        cmb = new SqlCommandBuilder(sa); 
        sa.MissingSchemaAction = MissingSchemaAction.AddWithKey; 
        cmd.Transaction = oTrans; 
        sa.Fill(ds, "yourtablename"); 
        DataRow drNew; 
        int x = 0; 
        foreach (DataRow dr in dtMealsData.Rows) 
        {
        if (Int32.Parse(dr["MealDetailsID"].ToString()) == 0) 
           { 
            drNew = ds.Tables[0].NewRow(); 
            drNew["MealTemplateID"] = dr["MealTemplateID"]; 
            drNew["WeekNumber"] = dr["WeekNumber"]; 
            drNew["DayOfWeek"] = dr["DayOfWeek"]; 
            ds.Tables[0].Rows.Add(drNew); 
            } 
        } 
        sa.Update(ds.Tables["yourtablename"]); 
        oTrans.Commit(); 
        oConn.Close(); 
        }
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a naming convention for the following scenario: I have a project which
I have a scenario where customers are asking to develop a new project on
The Scenario I have an ASP.NET web project. I want to be able to
We've got into a very tricky scenario in a project. We have used lot
My scenario is such that I have a VB.NET project in SVN and I
Consider this scenario: I have a project with two modules and one common module
Scenario: You have a reasonably sized project with some forms, classes, etc. Question: How
My common scenario: I have a web app and a test project in the
the scenario is i have a form in my Yii project that will take
Consider this scenario. I have a small enterprise project dev environment. We use archiva

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.