Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1309
  • Last Modified:

Adding to Gridview from empty table

Hello,

I'm trying to use a Gridview to add data to a dataset Datatable starting with a blank Gridview.  I know the columns for it and they fixed.  What I would like to do is be able to have a blank row in the Gridview show up on page load and then be able add N number of rows.  In the end, i'd like to do some calculations on the data and then submit it to a DB.  but thats later on down the road.  My first step is to show a blank GridView and be able to add to it.  Any ideas?  

thanks,
0
kevinmeredith
Asked:
kevinmeredith
  • 4
  • 3
1 Solution
 
ITTechSolverCommented:
1) empty row insert:
Try to look at this. Btw there are many of modified gridviews, maybe you can find even better or somebody recommends his best.
http://www.codeproject.com/useritems/GridView_with_insert_line.asp
0
 
kevinmeredithAuthor Commented:
thanks ITTechSolver.

I'm trying to look for something that will work using just the GridView and add another control like this is doing.  Any ideas?

thanks
0
 
kevinmeredithAuthor Commented:
I was also wondering how i could do this using a DataSet in and not use a SQL DB.  thanks again for your help, i reallly appreciate it
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
ITTechSolverCommented:
I think you can use only a table from a dataset, but you can use ObjectDataSource and use some methods there. Then you can write down method that will cooperate with whole dataset.
My colegue is like you, yesterday he asked me the same question and my answer was to use no data - gridviewrow that have display: disabled; style setup. I will ask him after 8 hrs, how he solved that.
I think you can access at event RowDataBound, GridViewRow and set the style for it. I know, this is poor sollution. ;)
0
 
kevinmeredithAuthor Commented:
thats what i want to do is use a table from a dataset.  definitely let me know what he says.  thanks!
0
 
ITTechSolverCommented:


So the first row is some nodata row at the table.

I think, You can bind DataTable to the GridView as DataSource - from ResultSet get your disered table. You have to manually call DataBind(). I know, that I did some DataTableDataSource, if it will not work..
// He used system that I proposed, but instead of style setup, he used Visible change (this is his code):
 
        protected void gv_RowDataBound(Object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow && ((GridView)sender).Rows.Count < 1)
            {
                e.Row.Visible = false;
            }
        }

Open in new window

0
 
kevinmeredithAuthor Commented:
thanks ITTechSolver
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now