Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
Selected Row as SQL parameter
posted

I have a WebGrid and and a FormView on a webpage. Both are bound to different SqlDataSource objects.  The WebGrid is set to allow Single row selection.  I would like to use the Data Key of the selected row in the WebGrid as a Select Parameter for the FromView's SqlDataSource, similar to the way you can do with a GridView:

 <SelectParameters>

<asp:ControlParameter ControlID="gvClientList" Name="ClientID" PropertyName="SelectedValue" Type="Int32" />

</SelectParameters>

Any idea how to make this work with the WebGrid?

  • 5
    posted

    I am facing the problem too.

    Current solution is to set a HiddenField.value =  the selected value.  and use the HiddenField.value as the parameter for the FormView's datasource.

        protected void UltraWebGrid1_SelectedRowsChange(object sender, SelectedRowsEventArgs e)
        {
            foreach (UltraGridCell cell in e.SelectedRows[0].Cells)
                if (cell.Key == "the_key")
                {
                   HiddenField1.Value = cell.Value.ToString();
                }
        }