Tuesday, November 24, 2009

query on datagrid

Hi

I want to query a datagrid on the page. possibly using Linq.

My purpose is to extract data of a column into an IList:-
currently doing like:-
for each(raddatagriditem item in radgrid.items)
{
lst.add(item["uniquecolumnname"].text);
}

but Due to performance concerns, I want to use Linq directly to populate "uniquecolumnname" string  values to another Ilist<string>.

please suggest how to query a datagrid item collection directly.

Cheers-Hemant
+919555798309
email removed

 

Reply 1

Hi hemantrhtk,

Do you mean get all the values of “uniquecolumnname” from DataGridView (You have said Linq, so it might be DataGridView not DataGrid, right?)?

If my understanding is correct, you can use this code to get value
foreach (DataGridViewRow dgvRow in myDataGridView1.Rows)
{
lst.Add(dgvRow.Cells["uniquecolumnname"].Value);
}
If I misunderstood you, please feel free to tell me.

Sincerely,
Kira Qian

Reply 2

Hi,
You can also use DataTable.Select(filterExpression) instead.




With best regards, Yasser Zamani

Tuesday, October 20, 2009

SpSiteDataQuery with more than 256 conditions.

Hi

I am getting error :-
Incorrect syntax near 'UserData'.
System.Data.SqlClient.SqlException: Too many table names in the query. The maximum allowable is 256.

if I use spsitedataquery with more than 256 conditions.

at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.SharePoint.Utilities.SqlSession.ExecuteReader(SqlCommand command, CommandBehavior behavior) at Microsoft.SharePoint.SPSqlClient.ExecuteQuery(Boolean& bSucceed) at Microsoft.SharePoint.Library.SPRequestInternalClass.CrossListQuery(String bstrUrl, String bstrXmlWebs, String bstrXmlLists, String bstrXmlQuery, ISP2DSafeArrayWriter pCallback, Object& pvarColumns) at Microsoft.SharePoint.Library.SPRequest.CrossListQuery(String bstrUrl, String bstrXmlWebs, String bstrXmlLists, String bstrXmlQuery, ISP2DSafeArrayWriter pCallback, Object& pvarColumns) at Microsoft.SharePoint.SPWeb.GetSiteData(SPSiteDataQuery query) at.......


Did anybody faced this issue before ?


Cheers-Hemant
EMAIL REMOVED

 

Reply 1

Can you include the CAML query you are trying to run, any view field set and background on what you are trying to achieve?




My SharePoint Blog - http://www.davehunter.co.uk/blog

Reply 2

is it something to do with length of the caml query possibly?

Reply 3

The Query property of the SPSiteDataQuery is a string.  I don't believe the CAML Query has a max length.




My SharePoint Blog - http://www.davehunter.co.uk/blog

Thursday, October 15, 2009

detect if new spfile is uploaded

Hi

Is there a way to detect if
a new spfile is uploaded in document library/ old spfile is replaced for the same item
or
only the meta data have been edited. (may be in itemupdated eventhandler.)




Thanks & Regards
Hemant Kumar
EMAIL REMOVED

Reply 1

When a file is replaced, the ItemUpdated event is triggered.  The same is true if you just change the metadata for the file.  Not sure if it's relevant to you, but replacing an existing file does not call ItemDeleted and ItemAdded.  In other words, it's not a delete and add operation.




Randy - http://sharepointhawaii.com/randywilliams

Reply 2

Hi,

Yes, as Williams’s information, both file replacing action and metadata updating action trigger ItemUpdated event.

And perhaps you need to distinguish them by BeforeProperties and AfterProperties.

Here is a  Williams article for detailed information when retrieving event’s  before and after value.

Hope this can help.

 

Best Regards,

-Aaron

Reply 3

Hi,

@hemantrhtk :) Please look at this link :http://www.synergyonline.com/blog/blog-moss/Lists/Posts/Post.aspx?ID=25
A great artcile for eventhandler.

Best Regards,

-Aaron

Reply 4

Hello Aron

Could you suggest , possibly what is is the column /property name which changes while new doc is uploaded/previous doc is overridden.

I tried the same thing before starting this thread with all the properties in loop , but could not figure out the possible column/property name.

Cheers-Hemant