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

Grid not populating

2 Answers 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Yan Moura asked on 30 Jun 2020, 06:15 PM

Not lucky getting RadGrid populated. I have a RadAutoCompleteBox where user can a code used as parameter of a stored procedure and the result should populate the grid in three columns. I tried to made it as simpler as possible but my grid is not showing up anything. 

My code ASPX:

<form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
     
    <telerik:RadAjaxManager ID="ajaxmanager1" runat="server" EnableAJAX="true">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAutoCompleteBox1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadAutoCompleteBox1" LoadingPanelID="radloadingpanel1" />
                    <telerik:AjaxUpdatedControl ControlID="lblOEValue" LoadingPanelID="radloadingpanel1" />
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="radloadingpanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="btnSearch">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadAutoCompleteBox1" LoadingPanelID="radloadingpanel1" />
                    <telerik:AjaxUpdatedControl ControlID="lblOEValue" LoadingPanelID="radloadingpanel1" />
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="radloadingpanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
     
    <telerik:RadAjaxLoadingPanel ID="radloadingpanel1" runat="server" AnimationDuration="0" InitialDelayTime="1000">
    </telerik:RadAjaxLoadingPanel>
     
    <telerik:RadAutoCompleteBox runat="server" ID="RadAutoCompleteBox1" ClientID="RadAutoCompleteBox1" >
        <!-- I supressed details because auto complete box is working fine -->
    </telerik:RadAutoCompleteBox>
     
    <telerik:RadGrid ID="RadGrid1" runat="server" autopostback="true">
        <MasterTableView AutoGenerateColumns="true">
            <Columns>
                <telerik:GridBoundColumn DataField="Description" UniqueName="Description">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ConditionsAndOptions" UniqueName="ConditionsAndOptions">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="RetailPrice" UniqueName="RetailPrice">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
     
    <asp:Button id="btnSearch" Text="Search" OnClick="btnSearch_Click" autopostback="true" runat="server"/><br />
     
    <div style="display:none">
        <asp:label ClientID="lblOEValue" id="lblOEValue" ClientIDMode="Static" autopostback="true" visible="true" runat="server" ></asp:label>
    </div>
</form>

 

My VB code:

Protected Sub RadAutoCompleteBox1_EntryAdded(sender As Object, e As Telerik.Web.UI.AutoCompleteEntryEventArgs)
    lblOEValue.Text = e.Entry.Text
End Sub
 
Protected Sub RadAutoCompleteBox1_EntryRemoved(sender As Object, e As Telerik.Web.UI.AutoCompleteEntryEventArgs)
    lblOEValue.Text = ""
End Sub
 
Protected Sub btnSearch_Click(sender As Object, e As EventArgs)
     Dim myConn As SqlConnection = New SqlConnection(ConfigurationManager.AppSettings("myconnection"))
    
Dim adapter As SqlDataAdapter = New SqlDataAdapter
    Dim myDataTable As New DataTable
    adapter.SelectCommand = New SqlCommand("EXEC [dbo].[] '" + lblOEValue.Text + "'", myConn)
    myConn.Open()
    adapter.Fill(myDataTable)
    RadGrid1.DataSource = myDataTable

    myConn.Close()

End Sub

 

What am I missing here?

2 Answers, 1 is accepted

Sort by
0
Yan Moura
Top achievements
Rank 1
Veteran
Iron
answered on 30 Jun 2020, 06:34 PM

Never mind... I added the Rebind() method before to close the connection and it did the trick... Just in case someone run in the same issue:

Protected Sub btnSearch_Click(sender As Object, e As EventArgs)
    Dim myConn As SqlConnection = New SqlConnection(ConfigurationManager.AppSettings("myconnection"))
    Dim adapter As SqlDataAdapter = New SqlDataAdapter
    Dim myDataTable As New DataTable
    adapter.SelectCommand = New SqlCommand("EXEC [dbo].[] '" + lblOEValue.Text + "'", myConn)
    myConn.Open()
    adapter.Fill(myDataTable)
    RadGrid1.DataSource = myDataTable
    RadGrid1.Rebind()
    myConn.Close()
End Sub
0
Doncho
Telerik team
answered on 03 Jul 2020, 08:37 AM

Hi Yan,

I am glad to know you have found a resolution to the issue.

Thank you for sharing it with the community, so that other developers can also benefit from it in the future!

Kind regards,
Doncho
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Grid
Asked by
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Answers by
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Doncho
Telerik team
Share this question
or