1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to display data using grid view in asp.

Discussion in 'C#' started by daljit, Nov 1, 2010.

  1. #1
    hi me is new with asp .i don,t no how to display data from database using grid view in asp. thank to all dp member .Please help me.......
    SEMrush
     
    daljit, Nov 1, 2010 IP
    SEMrush
  2. shiv.cec

    shiv.cec Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try tihs code

    protected void Page_Load(object sender, EventArgs e)
    {
    bindgrid();

    }


    private void bindgrid()
    {
    SqlConnection sqlConnection = new SqlConnection ( "connectionString" );
    SqlDataAdapter sqlDataAdapter = new SqlDataAdapter ( "Select * From TableName", sqlConnection );
    DataSet dataSet = new DataSet ();
    GridView1.DataSource = dataSet;
    GridView1.DataBind ();
    }
     
    shiv.cec, Nov 1, 2010 IP
  3. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,681
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #3
    For a much more basic example:

    <asp:GridView ID="Gridview1" runat="server" DataSourceID="SqlDataSource1" />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="connectionstring" SelectCommand="SELECT * FROM [TableName];" >
     
    AstarothSolutions, Nov 2, 2010 IP
  4. Sergei322

    Sergei322 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You should start here asp.net/get-started
     
    Sergei322, Nov 8, 2010 IP
  5. prkishnani

    prkishnani Peon

    Messages:
    164
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi.....

    There are two ways bind a database table with datagrid
    1) With property window that is also called bound connectivity.
    2) With Code that also called unbound connectivity.

    Web Designer | Real Estate Web Design
     
    prkishnani, Nov 8, 2010 IP
  6. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    yes this is the most basic way to process this request
     
    srisen2, Feb 8, 2011 IP