Hi team,
We are using webdataGrid.We are trying to copy data form webdataGrid in to a Datatable after a filter, but it will copy all data from the webdataGrid(we need only filtered data).
Code using for copy data : DataTable dt = this.wdgDataload.DataSource as DataTable;
How to copy filtered data only from Infragistics webdataGrid in to a Datatable(cod bebehind)
Version : 10, 2, 20102, 2158
Please do the needful.
Regards,
Narayanan.
Hello,
Since you are using DataTable as data source for your grid, you could clone this data table in order to get its schema, and then to populate the new data table based on the rows collection of the grid. So the code will looks like:
DataTable coppy = ((DataTable)WebDataGrid1.DataSource).Clone();
foreach (GridRecord rec in WebDataGrid1.Rows)
{
coppy.Rows.Add(((DataRowView)rec.DataItem).Row.ItemArray);
}
Please let me now if you have any further questions.
Hello,
I am just checking about the progress of this issue. Let me know If you need my further assistance on this matter?
Thank you for using Infragistics Components.
Hello Hristo,
Its Working fine,
Thanks!!!!!!!!!!!!!!!!!!!!!!!!!
I have tried your code but in my case the collection of rows(WebDataGrid1.Rows) only contains rows of visible page, not all rows of the Grid.
Hi ,
I have created a Webdata grid by assigning a Linq data source. But when I tried to get filtered data from Filtered event using above chunk of code Datasource is getting nothing(null value).Below I have pasted my code
//Client Side
<ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="600px" Width="100%" DataSourceID="LinqDataSource1" DataKeyFields="RAW_ACCOUNT" EnableDataViewState="true" >
<Behaviors>
<ig:Paging PagerMode="NextPreviousFirstLast" PageSize="30">
</ig:Paging>
<ig:Activation>
</ig:Activation>
<ig:VirtualScrolling>
</ig:VirtualScrolling>
<ig:EditingCore>
<ig:RowEditing>
<EditModeActions EnableOnActive="True" EnableOnKeyPress="True" MouseClick="Single" />
</ig:RowEditing>
<ig:RowAdding>
</ig:RowAdding>
<ig:RowDeleting ShowDeleteButton="True">
</ig:RowDeleting>
</Behaviors>
</ig:EditingCore>
<ig:Filtering>
</ig:Filtering>
<ig:Selection CellClickAction="Row" RowSelectType="Single">
</ig:Selection>
<ig:RowSelectors>
</ig:RowSelectors>
<ig:Sorting>
</ig:Sorting>
<ClientEvents AJAXResponse="AjaxResponse" />
</ig:WebDataGrid>
</td>
</tr>
</table>
</div>
<asp:ScriptManager ID="scriptmanager1" runat ="server"></asp:ScriptManager>
<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="RADDBDataContext" EntityTypeName="" TableName="REF_ACCOUNTS" EnableDelete="true" EnableInsert="true" EnableUpdate="true">
</asp:LinqDataSource>
///Server sid coding
Protected Sub WebDataGrid1_DataFiltered(sender As Object, e As Infragistics.Web.UI.GridControls.FilteredEventArgs) Handles WebDataGrid1.DataFiltered
Try
' BindGrid()
Dim dt As DataTable = CType(WebDataGrid1.DataSource, DataTable).Clone
Dim dt1 As New DataTable
dt1 = CType(Ds.Tables(0), DataTable).Clone
For Each rec As GridRecord In WebDataGrid1.Rows
dt1.Rows.Add(CType(rec.DataItem, DataRowView).Row.ItemArray)
Next
Catch ex As Exception
End Try
End Sub
Awaiting for your response
and
Your help is greatly appreciate.
Thanks
Madhu Parappa