How to write values in DataGridView

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mzahid
    New Member
    • Dec 2009
    • 3

    How to write values in DataGridView

    Hellow All
    I am new in ASP.Net Application. I have a page with some TextBoxes and GridView. I have Done the Values of Textboxes save into Invoice Table and i want to save Invoice Detail values through DataGridView, But the DataGridView behave readonly.
    In Windows Application form i can write in DataGridView (As many Record) and click save Botton then textboxes value save in Invoice table & DataGrid Values save in Invoice Detail Table. using this
    Code:
     foreach (DataGridViewRow dr in dgview.Rows)
     {
       if (dr.Cells[1].Value != null)
       {
         CMS.Components.WEB.Invoice_Detail objd = new CMS.Components.WEB.Invoice_Detail();
         objd.Description = Convert.ToString(dr.Cells["Description"].Value);
         objd.Quantity = Convert.ToString(dr.Cells[2].Value);
    How can i use this senerio in ASP.Net Application?
    Last edited by Frinavale; Dec 9 '09, 02:45 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    In ASP.NET you don't have a DataGridView available to you.
    You have a GridView instead.

    They are very similar but not quite the same since they are developed for different environments.

    So, what you need to do is create an Edit Template for your columns. In each edit template you need to define the appropriate controls that will let the user edit the record. These controls will be displayed when the user clicks the "edit" button.

    All the information you need on the GridView and any other .NET controls can be found in the MSDN Library. This resource should get you pointed in the right direction....th ere are multiple articles on the GridView there. I recommend bookmarking the MSDN Library and using it as your primary resource when developing in .NET.

    Also, take a look at the TemplateField as well. You use the TemplateField to define the Edit Template that I was talking about... check it out :)

    -Frinny

    Comment

    Working...