Hot answers tagged

2

Existing code that utilizes object model and runs within IIS will continue to work without recompilation (if compiled for AnyCPU or 64-bit). As when upgrading from SPS 2003 to SharePoint 2007 the upgrade process inserts assembly binding redirects from old assemblies to new assemblies (here 12.0.0.0 to 14.0.0.0) making the code automatically redirect to the ...


2

I think the problem is that you on post backs do not create the ObjectDataSource object and configure the SPGridView object. Refactor your code to do this in the CreateChildControls() method that you must override from the base class. Also call grid.DataBind() in the PreRender phase and not in the Render phase. Here is another useful article on the ...


2

Please check this post - http://www.fivenumber.com/export-spgridview-to-excel-spreadsheet-in-sharepoint-2007/


2

These 3 members are used to handle EmptyData in the SPGridView. EmptyDataRowStyle EmptyDataTemplate EmptyDataText Also check out this link for more info Update 1: If you just want to show the headers even though there are no data, use the ShowHeaderWhenEmpty property. Update 2: Check the list of properties and members for the SPGridView here.


2

You can create a view using SPView class and in query give Author=[Me] and set this view as default view About the default "All Items" view, set its permission to be viewable to only Administrators or Group with Full Control... See How to create SPView Programmatically and Programmtically create SPView Let me know if you need more help!


2

Yes, it is possible but it is kind of a hack. Step 1: Make your filter values pretty For this, you'll need to create a class inheriting from SPGridView and override the GetCallbackResult function: public class SPFilterGridView : SPGridView { protected override string GetCallbackResult() { string result = base.GetCallbackResult(); // do ...


1

I find :) e.Row.Height = new Unit(25); if (grid.Columns.Count > 1) for (int i = 1; i < grid.Columns.Count; i++) e.Row.Cells[i].Wrap = false;


1

As Arsalan mentioned you can create a SPView which does filter by Me. Here is the CAML query for doing that: query.Query = "<Where><Eq><FieldRef Name='Author' /><Value Type='Integer'><UserID Type='Integer' /></Value></Eq></Where>"; Here I have written a blog post which shows how to create a an SPView ...


1

Your class SimpleSPGrid does not inherit from anything, so I presume it inherits from Object. CreateChildControls() is a method of the Control class. Since the Object class does not have a CreateChildControls() method, SimpleSPGrid can't override it. Solution: Change the line Class SimpleSPGrid to Class SimpleSPGrid : Control Another option, if you ...


1

If table you want to bind SPGridView control with is SQL table then you can simply bind SPGridView with your SQL table, I would explain it in details but its already explained properly in this similar type of question, Sharepoint SPGridView Data Reneder-SQL


1

Yes it is possible, but you will need to implement sorting, filtering and paging yourself. This CodePlex project includes som basic examples. The key is that an SPQuery called on a list by list.getItems(yourSPQuery) (MSDN) will return list items that you can use to populate a DataTable or other datasource for the SPGridView


1

Yes, actually that control is the upgraded version of the SPGridView (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.spgridview.aspx). You should be able to use the same SHarePoint 2010 examples, many available http://www.srinisistla.com/blog/Lists/Posts/Post.aspx?ID=129 ...


1

I haven't yet got a chance to work with SP 2013. But if I had the same requirement in SP 2010, I may go with XSLTListViewWebpart. You can specify the name of the List and the view to be used in the webpart. Here is an example of adding XSLTListview webpart to the page: http://sharepointnadeem.blogspot.in/2012/08/programatically-add-xsltlist-view.html


1

You can try the below code, oGrid.AllowFiltering = true; oGrid.FilterDataFields = "Title"; //tells the SPGridView what columns we want to be able to filter on. oGrid.FilteredDataSourcePropertyName = "FilterExpression"; oGrid.FilteredDataSourcePropertyFormat = "{1} like '{0}'"; //property provides the format for our filter expression in a SQL-like syntax. ...


1

Here's an example on how to use the SharePoint:SPMenuField on a SPGridView. Basically, you first have to add a SharePoint:MenuTemplate control, then a SharePoint:SPMenuField to the SPGridView columns collection, with the MenuTemplateId pointing to the ID of the SPMenuField control previously created.


1

Filtering oGrid.AllowFiltering = true; oGrid.FilterDataFields = "Title"; //tells the SPGridView what columns we want to be able to filter on. oGrid.FilteredDataSourcePropertyName = "FilterExpression"; oGrid.FilteredDataSourcePropertyFormat = "{1} like '{0}'"; //property provides the format for our filter expression in a SQL-like syntax. Sorting ...


1

You can actually add XSLTListViewWebPart control in your Application Page and that should work exactly the same as list default page.. See XSLTListViewWebpart in Sharepoint 2010 Uncovered Download the XSLTListViewWebPart Declaration, Set appropriate properties and you are good to go..


1

Thanks for the responses, Actually I came across a remedy in a similar article Referring to tha post answer, in my code I invoked the below javascript OnClientClick event of the LinkButton. function setFormSubmitToFalse() { setTimeout(function () { _spFormOnSubmitCalled = false; }, 3000); return true; }


1

Yes it is possible, here is a basic example: protected void Page_Load(object sender, EventArgs e) { const string ConnectionString = @"Persist Security Info=False; Integrated Security=SSPI; Server=hercules\sqlexpress;Connect Timeout=30;Database=TestDB;"; SqlConnection con = new SqlConnection(ConnectionString); SqlCommand cmd = new ...


1

you can try full rest api and JQuery. Attach a change listener using jquery to your controls and on that listener you can use the next code $.ajax({ url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('your_list')/items(your_id)", type: "POST", contentType: "application/json;odata=verbose", headers: { "IF-MATCH": ...


1

Tried any of these examples (sorting must be "implemented" when using a DataSource other than the a List/View or result of SPQuery)? http://www.threewill.com/2010/08/the-great-and-powerful-spgridview/ http://sharethefrustration.blogspot.com/2010/02/spgridview-webpart-with-multiple-filter.html


1

Dont forget to set the 'onSorting' = 'your_event_handler', and give each sortable column a 'sortExpression'. I also advise declaring the DataTable as a global variable so you can cache the data for sorting during the event. *Beware the e.SortDirection stays 'Ascending' unless you deal with it, so instead I use a work around and track the current column name ...


1

It is difficult to troubleshoot since you didn't post all the code... I would make sure your BoundField is setup correctly and the SortExpresssion property is being set to the correct column in your DataTable: BoundField column = new BoundField(); column.DataField = name; column.SortExpression = name; column.HeaderText = name; If that doesn't work, read ...


1

Have you tried? grid.Columns[i].ItemStyle.Width = 200


1

I remember I also had this problem a while ago. And if I remember correctly, the only way to change the format of the date in the filter is to change the regional settings of the site. Go to Site Actions -> Site Settings and under Site Administration you will find Regional Settings. Here you can change under Locale how your date is formatted. For example, ...


1

I hope you're calling the code in right order. protected override void CreateChildControls() { // you code here Controls.Add(yourgridviewid); //Important to call this after Control.Add... yourgridviewid.PagerTemplate = null; base.CreateChildControls(); }


1

Ok. I was being silly. I'm using a visual webpart, but the blogs I've been reading from were for 2007 webparts. In my OnInit, I was setting spGrid = new SPGridView(); dataSource = new SPDataSource(); which of course reset all the settings of the SPGridView and SPDataSource I set in the ascx page. Therefore AutoGenerateColumns were set back to true, ...


1

Why? My best guess is... inside views SharePoint can use the ID to build a URL to the item. To fix your issue, it will probably be easiest for you to just iterate over the DataTable rows and trim off the id;#.


1

Use the build-in webdeveloper tool in the browser (F12) and inspect the element. I'm pretty sure it's just border around the contextmenu div. Add the below to your CSS file and brand it. Beware that this will change it for all contextmenus on your site using your CSS file, so you might want to narrow it down to your custom list. Over all: .s4-ctx{ } ...



Only top voted, non community-wiki answers of a minimum length are eligible