views:

1231

answers:

1

Hi,

I have a Gridview in which no rows populated initially. means i am not setting any datasource to gridview.I have to populate gridview by adding footerrow.I have given visibility of footerrow as true.So one error is coming as 'Object not set to an instance of an object'.what may be the reason for this? Can anybody help?

Actually i need to add data into the Gridview through the FooterRow.After inserting a few records,i need to insert this data into the database.So, i want this Gridview only to insert data into the database.For a particular "FileID", i have many records,thats why i am using Gridview.Is there any other method for this?

+2  A: 

See this question: How to insert a Row in GridView.

The object reference error is probably because you have set no datasource for the GridView. In such cases, the Gridview will not render.

Edit:

I have already linked to another question which provides a very useful link to accomplish the type of functionality you desire. Since you appear not to have found it, here is the relevant link - How to easily insert row in GridView with SqlDataSource?

The article shows how you can use the EmptyDataTemplate of the GridView to enable record insertion using a GridView. Note that you will have to modify the logic a little to insert a group of records in one go, rather than one at a time.

If you have a problem with this solution, please clarify via comments.

Cerebrus
So what can i do to add rows to gridview in runtime
Nandini
Did you check the question I linked to and the links posted therein?
Cerebrus
Somewhat doubtful....
ck
What is doubtful, Chris? Without seeing code, I'm shooting in the dark here. ;-)
Cerebrus
I have seen the link,Cerebrus,but i dont want data to be selected from the database.If i select data from the database,the selected values from the database will also be inserted with the new records.That is the problem.Can you help me please?
Nandini