Search code examples
c#sqlsqldatasourceext.netlinqdatasource

How to change this Ext.Net example to use Sql instead of Linq?


I am going by this example and trying to have it use a SqlDataSource instead of LinqDataSource. I can get the data to display in the table, but the form does not fill with the data when I select a row. I think these are the relevant bits of code:

protected void RowSelect(object sender, DirectEventArgs e)
{
    string employeeID = e.ExtraParams["EmployeeID"];

    Employee empl = Employee.GetEmployee(int.Parse(employeeID));

    this.FormPanel1.SetValues(new {
        empl.EmployeeID,
        empl.FirstName,                          
        empl.LastName,
        ...........
    });
}

And

<SelectionModel>
    <ext:RowSelectionModel runat="server" Mode="Single">
        <DirectEvents>
            <Select OnEvent="RowSelect" Buffer="250">
                <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{FormPanel1}" />
                <ExtraParams>
                    <ext:Parameter Name="EmployeeID" Value="record.getId()" Mode="Raw" />
                </ExtraParams>
            </Select>
        </DirectEvents>
    </ext:RowSelectionModel>
</SelectionModel>

protected void Store1_Refresh(object sender, StoreReadDataEventArgs e)
{
    this.Store1.DataBind();
}

Solution

  • This seemed to do the trick:

    <SelectionModel>
        <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Single">
            <Listeners>
                <Select Handler="#{FormPanel1}.getForm().loadRecord(record);" />
            </Listeners>
        </ext:RowSelectionModel>
    </SelectionModel>