Tuesday, 27 July 2010

Telerik RadGrid Frustration

RadGrid does not show or isn't visible on Page_Load?

Set a default value for your datasource SelectCommand of  the SqlDataSource of your Grid.

e.g.) <SelectParameters>

                <asp:ControlParameter Name="FleetNo" ControlID="txtFleetNo" PropertyName="Text" DefaultValue="0"/>
I discovered this error, when using a MaintainFleet page and and an AddFleet page.
The maintain page was working perfectly with the RadGrid. So I copied the code over for my new Add page.
I changed my dropdown from the Maintain Page to a textbox on the Add page. That field is the control parameter of the Select statement . And unless you set a default value for the Textbox one, the grid will not be visible until a postback is done. Of course the code was working on the Maintain page.... the Dropdown had been set with a default value in the code.

1 comment:

Stefan said...

Angela, I believe it is normal to specify a default value for the textbox. Thus the SQL select control parameter will be evaluated as expected and the Select query will filter the records in the grid on initial load even when no text is set in the textbox. You will most probably get the same result with MS GridView, and you already said that you set a default value for dropdown on a different page for the same purpose.

Bottom line: no need to be frustrated, just consider the options.