Saturday, 23 February 2013

How to implement cascading dropdownlist in gridview using asp.net.

How to implement cascading dropdownlist in gridview using asp.net. 
Introduction:

In this article I will explain how to implement cascading dropdownlist in gridview using asp.net.

Description:

In Previous posts I explained clearly how to implement ajax cascading dropdownlist using asp.net  and lot of articles regarding Gridview. Now I will explain how to implement cascading dropdown list in gridview using asp.net. Here I am using previous implemented article ajax cascading dropdownlist in asp.net to bind data to dropdownlists.

After that I am binding the data to gridview for that first design table in database and give name UserInfomation

ColumnName
   



ColumnName
DataType
UserId
Int(set identity property=true)
UserName
varchar(50)
LastName
varchar(50)
Location
varchar(50)


After completion table creation add ajax reference to your application because here I am using ajax cascading dropdownlists bind to gridview and design your aspx page like this


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Cascading Dropdownlist Sample</title>
</head>
<body>
<form id="form1" runat="server">
<ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"/>
<div>
<asp:GridView runat="server" ID="gvdetails" DataSourceID="dsdetails" AllowPaging="true" PageSize="10" AutoGenerateColumns="false" ShowFooter="true">
<RowStyle BackColor="#EFF3FB" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="UserId">
<ItemTemplate>
<asp:Label ID="lblUserId" runat="server" Text='<%#Eval("UserId") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="UserName">
<ItemTemplate>
<asp:Label ID="lblUserName" runat="server" Text='<%#Eval("UserName") %>'/>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddlCountry" runat="server"></asp:DropDownList>
<ajax:CascadingDropDown ID="CountryCascading" runat="server" Category="Country" TargetControlID="ddlCountry" LoadingText="Loading Countries..." PromptText="Select Country" ServiceMethod="BindCountrydropdown" ServicePath="DropdownWebService.asmx">
</ajax:CascadingDropDown>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="LastName">
<ItemTemplate>
<asp:Label ID="lblLastName" runat="server" Text='<%#Eval("LastName") %>'/>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddlState" runat="server"></asp:DropDownList>
<ajax:CascadingDropDown ID="StateCascading" runat="server" Category="State" TargetControlID="ddlState" ParentControlID="ddlCountry" LoadingText="Loading States..." PromptText="Select State" ServiceMethod="BindStatedropdown" ServicePath="DropdownWebService.asmx">
</ajax:CascadingDropDown>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Location">
<ItemTemplate>
<asp:Label ID="lblLocation" runat="server" Text='<%#Eval("Location") %>'/>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddlregion" runat="server"></asp:DropDownList>
<ajax:CascadingDropDown ID="RegionCascading" runat="server" Category="Region" TargetControlID="ddlregion" ParentControlID="ddlState" LoadingText="Loading Cities..." PromptText="select" ServiceMethod="BindRegiondropdown" ServicePath="DropdownWebService.asmx">
</ajax:CascadingDropDown>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="dsdetails" runat="server" ConnectionString="<%$ConnectionStrings:dbconnection %>"
SelectCommand="select * from UserInformation"/>
</div>
</form>
</body>
</html>
If you observe above code I used ajax cascading dropdownlist to bind in gridview. To bind data to dropdownlist and data tables design check this post ajax cascading dropdownlist using asp.net .After completion of bind data to dropdownlists use above code to place dropdownlist in gridview and bind data to gridview if you have any doubts just download the attached code to and check the details.

Here don’t forgot to set the connection string in web.config file here I am getting database connection from web.config file for that reason you need to set the connectionstring in web.config file like this

<connectionStrings>
<add name="dbconnection" connectionString="Data Source=SureshDasari;Integrated Security=true;Initial Catalog=MySampleDB"/>
</connectionStrings>
Demo


Populate One Asp.net Dropdown based on Selection in Another Dropdown


 Populate One Asp.net Dropdown based on Selection in Another Dropdown

 Introduction

Here I will explain how to populate one dropdown based on selection in another dropdown asp.net using c#.

Description

I have three dropdowns Country dropwdown, State dropdown, Region dropdown I need to populate states dropdown based on country dropdown and I need to populate region dropdown based on states dropdown for that what we have to do first design three tables in sql server with data like this



Monday, 18 February 2013

Application and the Session level events using Global.asax


Application and the Session level events using Global.asax

This file exposes the application and session level events in ASP.NET and provides a gateway to all the application and the session level events in ASP.NET. This file can be used to implement the important application and session level events such as Application_Start, Application_End, Session_Start, Session_End, etc.

Thursday, 14 February 2013

How To Add Color Picker in Firefox:

How To Add Color Picker in Firefox:

    Step1:Go to Tools menu in menu bar --After Select Add-On  and click that Add-on .

    Step2:Go to Search  in Add-on--Enter COLORPIX  and click enter button.

    Step3:Select ColorZilla -Click Install Now

    Step4:After Installation click Restart FireFox

    Step5:After that in Firefox we will see that collorzilla symbol.

How to Get Color of image using colorpickor

    Step6:Take Whatever image .Select which part color you want click colorpick.

    Step7:It will show html color,RGB color codes using that we get Color.

    Steep8:Using that color in paint or Adobe using we will design  or past it where you want.

Tuesday, 12 February 2013

Function for validating the Alphabets using javascript


Function for validating the Alphabets
Description:
                 Using javascript validating form for accepting only alphanumarics its a function in script tag .call that function name in textbox  onkeypress="return  Alphabets(event);"

Difference between DebugClass and Trace Class


 Difference between DebugClass and Trace Class

Debug Class
Provides a set of methods and properties that help debug your code. This class cannot be inherited.
Namespace: System.Diagnostics
Assembly: System (in system.dll)
Syntax:
public sealed class Debug

Wednesday, 6 February 2013

Insert Update Edit Delete Rows Record In GridView using sqldatasource

Insert Update Edit Delete Rows Record In GridView


In this example i am explaining how to Insert Update Edit Delete Records Rows In GridView With SqlDataSource Using C# VB.NET Asp.Net using SqlDataSource.

Tuesday, 5 February 2013

Using MVC3, Razor Helpers, and jCrop to upload and crop images.

Using MVC3, Razor Helpers, and jCrop to upload and crop images.


A common requirement for websites that allow user registration is the uploading of user profile images.  In many cases, this can be a bother for both user and developer.  The implementation of image cropping functionality has traditionally been somewhat cumbersome for developers, and users are generally pained by having to crop an image offline before uploading it, especially more inexperienced computer users.

We’ll explore how to quickly and easily create a solution using ASP.NET MVC3 and 2 of the new Razor helpers, the FileUpload and WebImage helpers and jCrop, an excellent jQuery plugin for image cropping.
Downloading/Installing Jcrop

Jcrop is available for download from the following link: Jcrop Webpage