This is a migrated thread and some comments may be shown as answers.

Entering records on a radgrid in a radwindow form that has not been saved

1 Answer 32 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Carina
Top achievements
Rank 1
Carina asked on 13 Dec 2012, 06:19 PM
Hello,

I have a rad grid on a form that has to be filled out with details on a particular document. In the SQL DB, the form has its own unique ID, and the radgrids in it, have their own table, with the form ID as a foreign key in those tables. When I first create a form, I want to be able to add records to the radgrids, but it will give be a null exception, because it does not have a form ID yet. Can I get some help with this? Would I have to use a session variable? if so, I have never used a session variable and I am new to this. I am using vb.net.

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 18 Dec 2012, 08:26 AM
Hi Carina,

Indeed one of the possible options is to save the form ID into the Session and based on it to bind the RadGrid to the corresponding records, the other option is to bind the RadGrid to and empty string collection – this could be used in case when the grid does not have any records to which it needs to be bound. For example:
<MasterTableView CommandItemDisplay="Top" ShowHeadersWhenNoRecords="true" >
Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
 Dim str() As String = New String() {}
 RadGrid1.DataSource = str
 End Sub
In this case the RadGrid will show its "No records to display." template but the "Add new record" button will also be shown and you could insert new records.

I hope this helps.

Regards,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Carina
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or