sqldatasource and gride view

H

Husam

Hi EveryBody:

How can I add a sqldatasource and gridview and configure them progrmaticlly?

any help or redirection will be appreciated

regard's

Husam
 
N

Nanda Lella[MSFT]

In the code behind, You can call

gridView1. DataSource = SQlDataSource1;
gridView.DataBind();

You should do the databind for any and all gridview related events you are
raising, like
Selecting, Updating, deleting, Paging etc..
And, initial databind could be in PageLoad, like

if(!Page.IsPostback)
{
gridView1. DataSource = SQlDataSource1;
gridView.DataBind();
}

you could also provide any DataSource related parameters in code behind
similar to..

SqlDataSource1.SelectCommand = "Select * from employees where employee
id=@id";
Parameter selectParam = new Parameter();
selectParam.DbType = DbType.Integer;
selectParam.DefaultValue = "100"; // Employee id...
SqlDataSource1.SelectParameters.Add(selectParam.)



Thank You,
Nanda Lella,

This Posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top