Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
hi Friend,

this is correct..but i want to be this without using data base..i did everything..now i want
if i click the cell so data is updating in a gv but it is not showing datatable..so i want to take a refresh button..
if i click on this so data should be update on a data table..
i am sending the code like this...

design page

<div style="text-align:center; background-color:SkyBlue; width:100%">
    <h3>GridView</h3>
      <asp:gridview ID="gridview1" runat="server" AutoGenerateColumns="false" AlternatingRowStyle-BackColor="Gray" OnRowDataBound="gridview1_OnRowDataBound" Width="100%">
       <Columns>
        <asp:BoundField DataField="Id" HeaderText="Id" ItemStyle-Width="50" />
         <asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="50" />
          <asp:BoundField DataField="City" HeaderText="City" ItemStyle-Width="50" />
       </Columns>
      </asp:gridview>
    </div>

code---


 protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {

                DataTable dt = new DataTable();

                dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id"), new DataColumn("Name"), new DataColumn("City") });

                dt.Rows.Add(1, "Anamika", "Bangalore");
                dt.Rows.Add(2, "Sunny", "Chennai");
                dt.Rows.Add(3, "Monika", "Bangalore");
                dt.Rows.Add(4, "Jyoti", "Chennai");
                dt.Rows.Add(5, "Radhika", "Jabalpur");
                dt.Rows.Add(6, "Imran", "Jammu");
                dt.Rows.Add(7, "Alok", "Delhi");
                dt.Rows.Add(8, "Amit", "Shamshabad");
                dt.Rows.Add(9, "Neetu", "Bhopal");
                dt.Rows.Add(10, "Jyoti", "Chennai");
                dt.Rows.Add(11, "Radhika", "Vidisha");
                dt.Rows.Add(10, "Pooja", "Pune");

                gridview1.DataSource = dt;
                gridview1.DataBind();

            }
        }
        protected void gridview1_OnRowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                for (int i = 0; i < e.Row.Cells.Count; i++)
                {
                    TextBox txt = new TextBox();
                    txt.Text = e.Row.Cells[i].Text;
                    e.Row.Cells[i].Text = "";
                    e.Row.Cells[i].Controls.Add(txt);
                }
            }
        }
    }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900