Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 5th, 2005, 12:40 PM
Registered User
 
Join Date: Dec 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default rebind dataset from web service after click button

hi,


i was developing a client web application which get the search file result from a web service , after getting the result, i would store it in a datagrid, then i would need to click the download button which retrieve the one value of the datagrid to be pass back to the web service, however, whenever it execute OnItemCommand="callDownloadFile" , it seems cant' retrieve the value from the datagrid, n i found tat whenever i click the download button , e.Item.DataItem will be NUL.. i know tat i need to rebind the result , however... i can't bind it properly..

anyone can help out with this? thanks..
Code:
private void Page_Load(object sender, System.EventArgs e)
{
//getAuthenticate();
if (!Page.IsPostBack)
{


callSearchFile();

}

callSearchFile();

}

public void callSearchFile()
{


DataGrid1.DataSource = service.SearchFile("text");
DataGrid1.DataBind();
}


public void callDownloadFile(Object sender, DataGridCommandEventArgs e)
{
if (e.Item.DataItem != null)
{


if(e.CommandName=="download")

{
Response.Write("second 3");
string path = ((Label)e.Item.FindControl("lblPath")).Text;
//Response.Write(strID);
}

}
else
{

Response.Write("second one");
}
Reply With Quote
  #2 (permalink)  
Old March 10th, 2005, 04:02 AM
Registered User
 
Join Date: Nov 2004
Location: Cape Town, , South Africa.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Create a Seperate BindData method and see

[C#]
void Page_Load(Object sender, EventArgs e){
if(Page.IsPostBack != "true"){
BindData();
}
}

void BindData(){
DataSet ds = new DataSet();
SQLDataSetCommand dsc;
dsc = new SQLDataSetCommand("SELECT * FROM myTable", "[connectionString]");
dsc.FillDataSet(ds, "myTable");
[Set the DataSource properties]
Page.DataBind();
}

Reply With Quote
  #3 (permalink)  
Old April 15th, 2005, 09:09 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The problem here isn't so much that you need to rebind. After a postback, the datasource of the grid will be NULL. Therefore, e.Item.DataItem will also be NULL.

Instead of getting data from e.Item.DataItem you need to get the data from the Items cells that are in the datagrid. That's where the data grid maintains its state.

e.Item.Cells(n).Text (for a standard BoundColumn).

-Peter
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a DataSet in a Web Service amirdiwan C# 2005 1 February 22nd, 2007 04:52 PM
How to Click a web button using VB code AJD Access VBA 6 June 6th, 2006 07:32 AM
How to Click a button on a web page in VB code AJD Beginning VB 6 0 June 2nd, 2006 12:08 PM
Populating Dataset with Web Service jpitzer .NET Web Services 3 July 18th, 2004 02:36 PM
Run a web page in java application on button click mathsyaka Java GUI 3 July 2nd, 2003 11:40 AM



All times are GMT -4. The time now is 12:57 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.