16,011,358 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by agnesn88 (Top 11 by date)
agnesn88
13-Mar-13 3:05am
View
First step : Creating Data base which will be our data source ,we do it using building the following data table :
Datastore.cs
using System;
using System.Data;
public class DataStore
{
public DataStore()
{
//
// TODO: Add constructor logic here
//
}
public static DataTable GetDataTable()
{
DataTable dt = new DataTable("Names");
DataColumn dc1 = new DataColumn("Name");
DataColumn dc2 = new DataColumn("Age");
dt.Columns.AddRange(new DataColumn[] { dc1, dc2 });
DataRow dr1 = dt.NewRow();
dr1[0] = "Ahmed";
dr1[1] = "27";
DataRow dr2 = dt.NewRow();
dr2[0] = "Peter";
dr2[1] = "30";
DataRow dr3 = dt.NewRow();
dr3[0] = "John";
dr3[1] = "20";
DataRow dr4 = dt.NewRow();
dr4[0] = "Ali";
dr4[1] = "30";
dt.Rows.Add(dr1);
dt.Rows.Add(dr2);
dt.Rows.Add(dr3);
dt.Rows.Add(dr4);
return dt;
}
}
Next step:
Creating Class file "Names" which will contain two properties (Data base columns) for "FirstName" and "Age". Like this :
Names.cs
public class Names
{
public Names()
{
//
// TODO: Add constructor logic here
//
}
private string _firstName;
private string _age;
public string FirstName
{
set { _firstName = value; }
get { return _firstName; }
}
public string Age
{
set { _age = value; }
get { return _age; }
}
}
Next Step:
Creating default.aspx page which will display and call the data.
Create GridView Control in your page :
<div>
<br />
<asp:GridView ID="NamesGridView" runat="server" ShowHeaderWhenEmpty="True" >
<br />
</div>
Notice that we set ShowHeaderWhenEmpty property to true to display columns names when empty.
In page load event we will write some code which will display the gridview even it empty :
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] { new DataColumn("Name"), new DataColumn("Age") });
NamesGridView.DataSource = dt;
NamesGridView.DataBind();
}
Notice that we created two columns Names as "Name" and "Age" .Now you can run the page the GridView should be displayed (try it!).
In code behind we will create a method which will connect to datastore and retrieve the data values. As the following :
[WebMethod]
public static Names[] GetNames()
{
List<names> list = new List<names>();
DataTable dt = DataStore.GetDataTable();
foreach (DataRow row in dt.Rows)
{
Names _names = new Names();
_names.FirstName = row["Name"].ToString();
_names.Age = row["age"].ToString();
list.Add(_names);
}
return list.ToArray();
}
Here we fill data values in the two properties (FirstName,Age) then we add it to List which accept Names Class Object as you saw above. And at the end we need to convert it to an array .
Notice that the method decorated with [Web Method] attribute which will allow us to get this method using client side code , and the method need to be declared as public and static also to get reached outside the Container class .
Next Step :
- Calling Server side method that will get the data values and bind the gridview using Jquery like this :
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
</script>
<script type="text/javascript">
function BindGridView() {
$.ajax({
type: "POST",
url: "Default.aspx/GetNames",
data: "{}",
contentType: "application/json",
dataType: "json",
success: function (data) {
for (var i = 0; i < data.d.length; i++) {
$("#NamesGridView").append("<tr><td>" + data.d[i].FirstName +
"</td><td>" + data.d[i].Age + "</td></tr>");
}
}
})
}
</script>
We can retrieve one column like "FirstName" or "Age" only, in the above code we create a loop to go through res
agnesn88
13-Mar-13 3:02am
View
we can't understand what you were trying to do...
agnesn88
13-Mar-13 2:59am
View
try this-->http://bitmiracle.com/pdf-library/
agnesn88
13-Mar-13 2:55am
View
--->read http://jquerygridview.com/
agnesn88
13-Mar-13 2:49am
View
Deleted
how about downloading a converter?? :)
agnesn88
13-Mar-13 2:45am
View
how about vb.net??? :)
agnesn88
13-Mar-13 2:40am
View
you can download some free sample codes here--->http://codeslibrary.net/sc.php?id=3188&code=Autocomplete%20for%20winform%20combo%20box
agnesn88
13-Mar-13 2:19am
View
The getItems(query) function enables you to define a Collaborative Application Markup Language (CAML) query that specifies which items to return. You can pass an undefined CamlQuery object to return all items from the list, or use the set_viewXml function to define a CAML query and return items that meet specific criteria.
agnesn88
13-Mar-13 2:15am
View
You can use the Context.User.Identity.Name to get the user name. If you use the Membership feature you can also use the GetUser method of the Membership class to get a MembershipUser to get information about the current logged in user.
agnesn88
13-Mar-13 2:00am
View
is that for android???
agnesn88
13-Mar-13 0:35am
View
try to debug
Show More