Saed Al Shaar Dev Tips and Tricks

.NET and SharePoint from a different angle!

Handling Delete Command in GridView

Hi Folks,

Here are how to handle the Delete Command in a GridView control.

Protected Sub GridView1_RowDeleted(sender As Object, e As System.Web.UI.WebControls.GridViewDeletedEventArgs) Handles GridView1.RowDeleted

If (e.Exception Is Nothing) AndAlso e.AffectedRows.Equals(1) Then
lblMessage.Text = “Deleted sccessfully.”
ElseIf (TypeOf e.Exception Is SqlException) AndAlso DirectCast(e.Exception, SqlException).Number.Equals(547) Then
lblMessage.Text = “Referential integrity issue.”
e.ExceptionHandled = True
Else
lblMessage.Text = “Cannot be deleted.”
e.ExceptionHandled = True
End If

End Sub

Happy programming!
Saed

Advertisements

Textbox to Accept only Number!

Hi Folks,
Many of the blogs or articles on the net talking about using JavaScript and type code to do that, there is an easier way to that with CompareValidator in ASP.NET.

Here is the CompareValidator you need to have:

ControlToValidate=TextBox1
Text=Enter Numeric Value
Operator=DataTypeCheck
Type=Integer

Happy programming!
Saed

Calculated Columns in SharePoint Lists Dilimiter Issue

Hi Folks,

There are many blogs and articles talking about the Calculated Columns in SharePoint or Excel , but few of them highlight the issue with the dilimiters of the formulas.

http://office.microsoft.com/en-au/windows-sharepoint-services-help/examples-of-common-formulas-HA010105479.aspx?CTT=3

While formulating the formula, you need to know what is the character used by your SharePoint to dilimiter the paramerters, usually it’s the comma (,), but sometimes it’s the simicoln (;).

So, if you are sure about the formula and it’s not working, then try to change the dilimiter and it will work.
Example:
=TEXT([Event Date],“MMM”)        
>>> can be changed to >>>>
=TEXT([Event Date];“MMM”)

Happy programming!
Saed

Executing SQL commands on SharePoint List

Hi Folks,

Some times you need to run some SQL commnads on a SharePoint List trying to copy some content from one column into another … etc.

The solution for this is Microsoft Access (2007/2010), simply create a new Access database.

Type the list URL:

Then choose the List you want:

Then create a new Query:

Then Run the query.

And it will update the List inside the SharePoint portal.

Happy programming!
Saed

LINQ Datasource and Error: Operator ‘=’ incompatible with operand types ‘String’ and ‘Int32’

Hi folks,

It’s an issue when you try to filter LINQ datasource within Visual Studio, where you choose Control and then it will show “==” in the Operator as follows:

When you try to run the page, it will give you and error saying:
Operator ‘=’ incompatible with operand types ‘String’ and ‘Int32’

All what you need to do is to change the Convert the Parameteres into the required data type as follows:

And it will magically work!

Happy programming!!
Saed

Report Viewer Control in Visual Studio

Hi Folks,

Here I would like to direct you to some of the useful video casts that I used to know more about the Report Viewer control that exists in Visual Studio 2005 till 2010.

First I will start with a simple report viewer video cast on Channel 9:
http://channel9.msdn.com/Blogs/trobbins/Introducing-the-Report-Viewer

Secondly, after that you need to know how to pass parameteres to the report, you can watch this in the following youtube video cast:
http://www.youtube.com/watch?v=sXJmRHgSAS8

I hope this will help!

Happy coding.

Changing Acive Directory Properties using ASP.NET VB.NET

Hi folks,

The IT Manager asked me to develop a new system for giving the employees the ability to change thier details in the Active Directory, and it took me aloooong time to figure out the way of doing this, in an easy way.
I would like to share with you the structore and the code of the application, for anyone who wants to do that 🙂
I posted the code into a project in CodePlex here:
Happy programming!
Saed

Post Navigation

%d bloggers like this: