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

How do remove a column from the autogenerated edit form

3 Answers 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kathy
Top achievements
Rank 1
Kathy asked on 30 Sep 2010, 03:34 PM
This is a 2 part question, but they should be pretty quick to answer:
1) I have a column in the grid that I have hidden and I don't want that column to show up in the autogenerated edit form.  I guess I need to catch some event to get that removed.
2) If I don't have this column visible, I still need to set the columns data so that I can do an insert ( the column is a foreign key ).  So I am just hardcoding the foreign key here.  How would I go about doing that so that the insert will work?
Thanks.

3 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 30 Sep 2010, 03:40 PM
Hello Kathy,

1) To hide a column from showing in the edit form you need to set ReadOnly="true" on the column.
2) If you're hard-coding it I don't an issue with the form being in insert or edit mode. Another approach would be to set the DefaultInsertValue on the column you want to default the value for.

Your column could look something like this:

<telerik:GridBoundColumn DataField="ForeignKey" ReadOnly="true" DefaultInsertValue="2">
</telerik:GridBoundColumn>

I hope that helps.
0
Kathy
Top achievements
Rank 1
answered on 30 Sep 2010, 05:28 PM
One last question: if I wanted to set the foreign key to a value from a session variable, how would I go about doing that?
Thanks for all the answers.  The readonly column thing worked great. 
0
Cori
Top achievements
Rank 2
answered on 30 Sep 2010, 07:43 PM
Hello Kathy,

I'm assuming you're using some kind of DataSource control (i.e. SqlDataSource, LinqDataSource, etc...). If so, you can just add an insert parameter to your data source of type SessionParameter. Like so:

<

 

InsertParameters>

 

 

   <asp:SessionParameter Name="ColumnName" SessionField="SessionName" />

 

 

</InsertParameters>

 


In the SessionField you put the session key that you're using to get that value.

I hope that helps.
Tags
Grid
Asked by
Kathy
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Kathy
Top achievements
Rank 1
Share this question
or