im new in asp and telerik i want to know how to show the value of the gridBoundColumn that has the employeeID and set it as default in the textbox of the GridBoundcolumn, so i want to know if its possible and if it is how to do it or a workaround
5 Answers, 1 is accepted
As I understand you would like to set a default value that will be used for a GridBoundColumn. Please correct me if I am wrong.
If the above is correct you can specify the DefaultInsertValue property for the column. The value defined there will be used initially for new items.
Telerik by Progress
hi Viktor ,
sorry for my horrible question i didnt know how to put it the thing is that i want to set the default value of the auto-generated textbox from the gridboundcolumn as soon the page loads.
And yeah i used the DefaultInsertValue and while it does what i want not quite since the text its onl what i insert in the property but i want the value to be the one of the GridboundColumn.
I dont know if i can explain myself the Gridboundcolumn gets the user's EmployeeID and i use that textbox to fill another form to insert some data related with that ID the thing is that the textbox its empty and i have to type the EmployeeID to fill the form, now i noticed that if i dont type anything in the textbox it does get the Gridboundcolumn value with the EmployeeID and does the insert succesfully so i dont have any problem getting the value but i want to eliminate the need of keep typing the EmployeeID when it can just show it while keeping the option of typing another ID and btw i have the light suspect im misunderstanding how the gridboundcolumn works but if u could tell me how to set a default value to a gridbound column's textbox with a sql data which already gets the value that would be nice
i hope i have explained im not really good explaining stuff
thanks for answering me
The DefaultInsertValue will populate the field in the column when inserting a new record. If you are editing a record the value will be retrieved from the data source. Thus, the default value will not be used in this case.
With that said, I am having a hard time understanding the scenario you would like to implement. Are you trying to populate external controls with data depending on the edited record in RadGrid? Or the scenario is different?
Telerik by Progress
Hi Viktor and Thanks for sticking with me,
Sort of, i want to populate a single autogenerated textbox that use the GridBoundColumn, so i can use that data as part of another insert, here is the only thing that is gonna be populated all the others input controls ill fill them myself.
Now the GridBoundColumn´s textbox that is the one i want to populate does get the value i want because if i fill all the controls but i leave the GridBoundColumn´s textbox blank it does insert the value im looking for in the new record.
So it is getting the value but i dont know how to populate GridBoundColumn´s autogenerated textbox with that data.
The easiest way would be not to show that control so it can only insert the EmployeeID thats currently signed in without any problem but i need to be able to have that data just as default because its gonna be most likely the one that its gonna be insert but theres gonna be an scenario that it might be change.
Now long story short i want to be able to get the GridBoundColumn´s value and show it in the textbox everytime i want to insert a new record but with the possibility to change it in case i need to input a different ID.
Like i said before the GridBoundColumn does get the right value but i want to display it in the textbox
Think about it like a Report fill at the moment to do the report i need the ID of the one who did the report i want that Id retrieved it by the GridBoundColumn showed in the control so theres no need to type it every single time but with the chance to input a different one in case its need it which again it already does that the only missing part is that it does not show the ID in the textbox its just blank letting the user thing that they have to type their ID which is not necessary to the in the moment signed in one
i hope i didnt make it harder to understand
Let me explain how the columns in RadGrid work. This applies for a GridBoundColumn and for the other column types.
By default a grid column is bound to a value in the data source. When you edit a row/cell the column editor will display the current value for the field. The user can change the value in the editor and update the field in the data source.
If the user inserts a new item the column editor will be empty by default. If you specify DefaultInsertValue it will be applied to the column editor initially when inserting an item.
With that said, from your description it seems that you would like to use a GridBoundColumn as a search field to look up related data. Note that such functionality is not supported by the grid columns.
If you would like to have a search feature and show the result in a RadGrid you can use an approach similar to the one from the example below. Note that the data in the second grid depends on the selection in the first one.
If you would like to keep all data in a RadGrid and filter it by an external control you can use an approach like the one in the following demo.
Telerik by Progress