In this article, I will explain you, How to retrieve data from two joined table using single LINQ Query. Here we have two joined table in mentioned diagram. Both tables are joined from dept_no, so if you want to retrieve record from both table like:
Retrieve emp_id and emp_name who belongs to IT department.
employeeEntities empl = new employeeEntities();
var query = from g in empl.emps
join m in empl.depts on g.dept_no equals m.dept_no
where m.dept_name == "IT"
select new
{
Emp_Name = g.emp_name,
Emp_ID = g.emp_id
};
dataGridView1.DataSource = query.ToList();
In this code, empl is the context object through which we can access columns of both tables. emp is the foreign key table map with dept table using dept_no column. Emp_Name and Emp_ID is the reference name , which are displayed on table. Bind the query result with the dataGridView.
[Solved] Rows cannot be programmatically removed unless the DataGridView is data-bound to an IBindingList that supports change notification and allows deletion. When you bind the Datagridview with List in windows form. You get error when you delete row from it. According to article title, first to implement your List from IBindingList interface, if you want to solve this issue. Suppose, you want to bind your DataGridView with this class, which is mentioned below:
public partial class userAccount
{
public decimal Account_No { get; set; }
public string Name { get; set; }
}
}
Then you write simple code for this :
List<userAccount> ua= new List<userAccount>();
ua.Add(new userAccount(){Account_No=1000000008, Name ="Jacob"});
dataGridView1.DataSource = ua;
After binding the DataGridview, you will write the code for remove row from dataGridview.
We all know about login form. In it, we have two fields first and second that are username and password. Both are stored in browser memory via HttpCookie. I mean to say when you first-time login into your account your username and passwords are saved into your browser cache. So, when you come again on your website, it did not ask username and password again, redirect on home page.
Before reading this article, if you want to know about cookie then watch mentioned video.Now, Lets start to save username and password in the cookies.
In this code we have a code in page load method. First to check, either Cookies are available or not. If cookies are available then check the username and password which are stored in the cookies. If both are matched then redirect to another page. When we click on button then first to match the username and password, if both are matched then saved the username and password into the cookies.
In this article, I will explain you, how to reload page after few seconds. This types of logics appear where web page refresh just after few seconds like yahoo cricket. By using Meta tag, we can implement in web technologies. I will give you an example of it. This article cover such things like : Watch full code video
Page Reload/ Refresh after 10 seconds.
By using code we can do reload/ refresh page.
By using AppendHeader( ) method we can solve this query.
Redirect after 5 seconds to new page.
Redirect page after session out.
By using meta tag's attribute, we can refresh webpage, in which we have two attributes i.e http-equiv and content. Let's, take an example:
If you want to do redirect page after few seconds then you should use meta tag at compile as well as runtime. In compile time, you can use meta tag with similar attribute which is defined in above code. The only one difference in both code i.e URL. URL pass in content as a attribute with some interval. Like:
Compile time :
<head runat="server">
<meta http-equiv="Refresh" content="10;url=Default.aspx" />
</head>
You can do the same code using c#
protected void Page_Load(object sender, EventArgs e)
{
HtmlMeta meta = new HtmlMeta();
meta.HttpEquiv = "Refresh";
meta.Content = "10;url=Default.aspx";
this.Page.Controls.Add(meta);
}
Thanks to google for blocking sites which contain deceptive material and fake download button. Many sites owners focus on ads and fake clicks. So they put download button just after important information, suppose your article is related to project download and you put download advertisement in place of actual download link. When visitor comes on your website and they click on advertisement. The whole deceptive material banned by google's safe browsing tech. By using this ,you can protect yourself or computer from malware and unwanted software.
Source : http://arstechnica.com/
Google already banned those site which contain wrong information and unwanted Softwares, you can say which breaks "Social Engg attacks".
In this article, I will explain you, How to use JavaScript code in ContentPlaceHolder of Master page. If your web page (Web Form=.aspx page) is inherit from master page then you must to use ClientID of the control to get the value. Like
document.getElementById("<%=Label1.ClientID%>");
By using above mentioned code we want to retrieve inner html text of the label. If you are using java script in simple web form which is not inherit from master page then you can use simple id of the control as parameter. Like
document.getElementById("Label1");
How to use JavaScript in Master page's Content PlaceHolder
Step-1 : Add a Master page also add web form.
Step-2 : Do Inherit web form from master page.
Step-3 : Write the below mentioned code in the content place holder of the web form.
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<input id="Button1" type="button" value="button" onclick = "check()"/>
<script type = "text/javascript">
function check()
{
var label = document.getElementById("<%=Label1.ClientID%>");
var textbox = document.getElementById("<%=TextBox1.ClientID%>");
alert("Label Value " + label.innerHTML + "TextBox Value " + textbox.value);
}
</script>
</asp:Content>
Note: Please mentioned javascript code at last position of the page.
This method returns integer type value, actually, it returns top tuple no of record from the table. Here I will provide you an example of ExecuteScalar ( ) method. By using this example you can retrieve top tuple no from the record.