Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Edit Column within a DataGrid

Status
Not open for further replies.

GavW

Programmer
Jan 13, 2006
58
GB
Hey guys.

I need some help with a problem that i am experiencing trying to add an edit column to my datagrid dynamically. The column is displaying fine i just cannot get the functionality to work with a dataset being consumed from a web service.

I have this functionality working when i have a DataSet embedded on the same .aspx page as my datagrid so i do not require assistance with that aspect of the code.

The only difference that i can see between the two scenarios is instead of selecting the datasource from the dropdown field within the datagrid properties I instead need to assign the datasource to the datagrid within the code. Unfortunately when I use the dataset that is not embedded within the page, selecting the edit command makes the datagrid disappear.

This is the code I have when referencing the data adapter and dataset within the same page. The data adapter selects all from my table. The edit command works perfectly using this method:

DA.Fill(dataSet11);
if ( !IsPostBack )
{
DataGrid1.DataBind ( );
}

Unfortunately I need the data adapter and dataset to come from a Web Service. The Web Method in this service is outlined below:

[WebMethod]
public DataSet WebService()
{
//Set up the data adapter to perform the query
string strSQL = "SELECT * FROM table";

OleDbDataAdapter adapter = new OleDbDataAdapter(strSQL, con);

DataSet ds = new DataSet();
adapter.Fill(ds, "table" );

//Return the dataset
return ds;
}

This returns the dataset which displays the same results as the "dataSet11" outlined in the previous example. The code within my application to consume this method looks like this:

localMethodsRef.Service1 service = new Application.localMethodsRef.Service1();
ds = service.WebService();

if ( !IsPostBack )
{
DataGrid1.DataSource = ds;
DataGrid1.DataBind ( );
}

The datagrid displays the exact same using these two methods it is just the edit command which does not function how i would like it to. Can anybody aid me with this problem I cannot see a way around it.

Thanks

GavW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top