Could anyone tell me whether datagrid in can be used without database bcos if it is used means not visible during runtime.. anyone can advise if u know in this regard.........

Recommended Answers

All 5 Replies

DataGrids, Repeaters, etc., do not have to be used with database connections, they can be bound with other collections. Take this example:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        <asp:DataGrid ID="myDatagrid" AutoGenerateColumns="true" runat="server">

And the code behind

protected void Page_Load(object sender, EventArgs e)
        List<string> myStrings = new List<string>() { "A", "B", "C" };
        myDatagrid.DataSource = myStrings;

The result here is a simple grid with these results


I hope that's the answer you're looking for? Alternately, DataGrids do not have to bound to anything at all, in which case they'll not even appear when you load the page.

commented: Nice to see someone giving examples but not doing peoples' work for them :) Instructive = good! +9

The above post is correct. I want to add when you use arraylist of objects, the public properties of the objects in that arraylist are similar to columns of your SQL queried data.

thank you... but i want a grid in such a way that i want text boxes in the grid to enter values and also it automatically increment the rows after pressing enter or tab at the last cell... i have designed the grid but it is not visible at run time..... cud u pls xplain

after receiving the mail when he click on the mail i need to get the mail in

plz help me,i need it
after receiving the mail when he click on the mail i need to get the mail in

commented: If you have a question please start a thread. Posting in a 2+ year old thread with a new question = not so great ;) -2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.