Could not load file or assembly 'System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencie


In this short asp.net tutorial you will learn how to get rid of this Could not load file or assembly 'System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified error.
Today when I tried to run my .aspx page while using visual studio 2008 I got this error.In my .aspx page I am using JSON (JavaScript Object Notation) and for JSON to work efficiently I was using System.Web.Services namespace.

I am giving all these details because I am not getting such error when I tried to run any of my .aspx webpage that just contain c# code. So let’s have a look over how to solve the problem.

To get rid of this error you just have to install .NET Framework 3.5 Service Pack 1 and that’s it. You can download the .NET Framework 3.5 Service Pack 1 microsoft website using this link http://www.microsoft.com/downloads/details.aspx?FamilyID=AB99342F-5D1A-413D-8319-81DA479AB0D7&displaylang=en

And if you found this link broken then go to google.com 

So this is the way to get rid of this Could not load file or assembly 'System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. nasty error.

Read more...

Delete multiple rows in a gridview in asp.net using c#

In this asp.net tutorial you will learn how to delete multiple rows in a gridview in asp.net using c#. During web development in number of occasions you may find requirement to delete the multiple rows in a gridview. Let's have a look over how to do so.


yourpage.aspx

<asp:gridview id="GridView1" runat="server" width="100%">
<Columns>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:CheckBox ID="chkid" runat="server" Text='<%# Bind("User_ID")%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Email" >
<ItemTemplate>
<asp:Label ID="lbl_Email" Text='<%# Bind("User_Email")%>' runat="server"></asp:Label>
</ItemTemplate>
<ItemStyle Font-Size="15px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="First Name" >
<ItemTemplate>
<asp:Label ID="lbl_first_name" Text='<%# Bind("User_First_Name")%>' runat="server"></asp:Label>
</ItemTemplate>
<ItemStyle Font-Size="15px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Last Name" >
<ItemTemplate>
<asp:Label ID="lbl_last_name" Text='<%# Bind("User_Last_Name")%>' runat="server"></asp:Label>
</ItemTemplate>
<ItemStyle Font-Size="15px" />
</asp:TemplateField>
</Columns>
</asp:gridview>

<asp:Button ID="Button1" runat="server" Text="Delete" OnClick="Button1_Click" />

yourpage.aspx.cs

protected void Button1_Click(object sender, EventArgs e)
{
foreach(GridViewRow row in GridView1.Rows)
{
CheckBox chkbox = (CheckBox)row.FindControl("chkid");
string uid = chkbox.Text;
if (chkbox.Checked)
{


con.ConnectionString=strcon;
com.Connection=con;
con.Open();
string query = "Delete from users where User_ID='"+uid+"'";
com.CommandText = query;
com.ExecuteNonQuery();
con.Close();
fillgrid();

}
}
}

Now let's first understand the code written in .aspx page.

It is quite simple I just put a gridview control in my page just like the tutorial I have written to display records in gridview. The only difference is that in very first <asp:TemplateField> I put a checkbox inside it's <ItemTemplate> and give the checkbox User_ID as a text which is the primary key in my users table. It is very much compulsory to provide unique/primary key to the checkbox so that deleteion of multiple rows can be achieved effeciently. And then in the end just below the gridview control I put the asp:button and using it's server side onClick event I have written the code to delete the multiple rows in a gridview.

In that code I am using the foreach loop which simply goes to each row of the gridview and then checked whether the checkbox of that row is checked or not, if the checkbox of that row is checked then it is simply deleting that row.

The fillgrid() function in the last that I m calling is to again displaying remaining records in the gridview after deletion of multiple records. As I have already written this function in my tutorial Displaying data from database in gridview that's why I don't write extra code other than deletion of multiple rows in a gridview in my this asp.net tutorial. If you want to know how to establish connection to the database and display records in a gridview then you must have to read this tutorial.

I hope now you understand how to delete the multiple rows in a gridview in asp.net using c#.

Read more...