Click here to Skip to main content
15,900,656 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionGridView not showing updations Pin
nagendrathecoder25-Aug-09 0:38
nagendrathecoder25-Aug-09 0:38 
AnswerRe: GridView not showing updations Pin
geeeeeeeetha25-Aug-09 0:44
geeeeeeeetha25-Aug-09 0:44 
GeneralRe: GridView not showing updations Pin
nagendrathecoder25-Aug-09 0:51
nagendrathecoder25-Aug-09 0:51 
AnswerRe: GridView not showing updations Pin
N a v a n e e t h25-Aug-09 0:44
N a v a n e e t h25-Aug-09 0:44 
AnswerRe: GridView not showing updations Pin
4anusha425-Aug-09 0:46
4anusha425-Aug-09 0:46 
AnswerRe: GridView not showing updations Pin
padmanabhan N25-Aug-09 0:48
padmanabhan N25-Aug-09 0:48 
GeneralRe: GridView not showing updations Pin
nagendrathecoder25-Aug-09 1:02
nagendrathecoder25-Aug-09 1:02 
AnswerRe: GridView not showing updations Pin
nagendrathecoder25-Aug-09 1:00
nagendrathecoder25-Aug-09 1:00 
This is my code for GridView and DataSource

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                    DataKeyNames="LocationCode" DataSourceID="SqlDataSource1" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
                                    <Columns>
                                          <asp:CommandField ShowSelectButton="True" SelectText="Edit" />
                                          <asp:BoundField DataField="LocationCode" HeaderText="Location Code" ReadOnly="True"
                                                SortExpression="LocationCode" />
                                          <asp:BoundField DataField="LocationDesc" HeaderText="Desciption" SortExpression="LocationDesc" />
                                    </Columns>
                              </asp:GridView>
                              <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=COMP2;Initial Catalog=Inventory;User ID=sa;Password=pes"
                                    ProviderName="System.Data.SqlClient" SelectCommand="SELECT [LocationCode], [LocationDesc] FROM [Location_Master] ORDER BY [LocationCode]">
                              </asp:SqlDataSource>



I am editing data in database manually by using SqlCommand class ExecuteScalar method like this.......

protected void btnSave_Click(object sender, EventArgs e)
      {
            //This method will update a record into Location_Master table
            try
            {
                  string connectionString = ConfigurationManager.AppSettings["ConnectionString"];
                  SqlConnection connection = new SqlConnection(connectionString);
                  connection.Open();

                  string save = "";
                 
                 
                        //String for updating a record into table
                        save = "update Location_Master set LocationDesc='" + txtBoxLocDesc.Text + "',CreatedBy='"+Session["userName"].ToString();
                        save = save + "',LastUpdateDate='" + System.DateTime.Now + "' where LocationCode='"+txtBoxLocCode.Text+"'";
                 
              
                  SqlCommand saveCommand = new SqlCommand(save, connection);
                  int rowsAffected = saveCommand.ExecuteNonQuery(); //Store the no. of rows added or updated

                  connection.Close();
                 
                 
            }
            catch (System.Exception ex)
            {
                  lblMessage.Text = ex.Message;
                  lblMessage.Visible = true;
            }
      }


After clicking that Save button, database is updating, but changes are not reflecting to GridView, i have to execute my application again to see changes in GridView.
GeneralRe: GridView not showing updations Pin
nagendrathecoder25-Aug-09 1:01
nagendrathecoder25-Aug-09 1:01 
GeneralRe: GridView not showing updations Pin
Blue_Boy25-Aug-09 1:10
Blue_Boy25-Aug-09 1:10 
GeneralRe: GridView not showing updations Pin
nagendrathecoder25-Aug-09 1:15
nagendrathecoder25-Aug-09 1:15 
AnswerRe: GridView not showing updations [modified] Pin
Amit Patel198525-Aug-09 1:15
Amit Patel198525-Aug-09 1:15 
GeneralRe: GridView not showing updations Pin
N a v a n e e t h25-Aug-09 1:18
N a v a n e e t h25-Aug-09 1:18 
AnswerRe: GridView not showing updations Pin
nagendrathecoder25-Aug-09 1:17
nagendrathecoder25-Aug-09 1:17 
QuestionChild node Not allowed in web.comfig Pin
maverick068124-Aug-09 23:45
maverick068124-Aug-09 23:45 
AnswerRe: Child node Not allowed in web.comfig Pin
N a v a n e e t h25-Aug-09 0:43
N a v a n e e t h25-Aug-09 0:43 
QuestionUser Control Pin
geeeeeeeetha24-Aug-09 23:30
geeeeeeeetha24-Aug-09 23:30 
AnswerRe: User Control Pin
padmanabhan N24-Aug-09 23:35
padmanabhan N24-Aug-09 23:35 
GeneralRe: User Control Pin
geeeeeeeetha24-Aug-09 23:52
geeeeeeeetha24-Aug-09 23:52 
QuestionDataList: Collecting IDs and TextBox values at same time Pin
Member 340288624-Aug-09 23:19
Member 340288624-Aug-09 23:19 
QuestionGenerate Events from Controls in ModalPopupExtender [modified] Pin
astrovirgin24-Aug-09 22:36
astrovirgin24-Aug-09 22:36 
QuestionASP.Net with Java Script Pin
Amit Patel198524-Aug-09 22:34
Amit Patel198524-Aug-09 22:34 
AnswerRe: ASP.Net with Java Script Pin
N a v a n e e t h25-Aug-09 0:50
N a v a n e e t h25-Aug-09 0:50 
QuestionCould not load file or assembly Pin
gtaure24-Aug-09 22:14
gtaure24-Aug-09 22:14 
Questionmenu index of a certain menu item.... Pin
RajpootRohan24-Aug-09 22:03
professionalRajpootRohan24-Aug-09 22:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.