AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 create/insert data via detailsview to gridview in a web service??
Posted by Sophia on  6/10/2011 1:38:33 AM Category: Asp.Net 2.0
Add to my favorites
Email to friend
You cannot vote on your own post
0

hihi i am doing a web service in c# in visual studio 2010 provide to Web site B to consume in the grid view

so basically i bind it with the web service...

i am able to retrieve, update and delete data i consume through web service

however i am not able to add a record through the details view

what i want is from the detail view click on new and key in the record and it will update the grid view

this is my code for insert but it give me error

<pre>
protected void DV_NewRoll_ItemInserting(object sender, DetailsViewInsertEventArgs e)
{
Label Roll_ID = (Label)DV_NewRoll.Rows[1].Cells[1].FindControl("Label1");
TextBoxRoll_Data = (TextBox)DV_NewRoll.Rows[2].Cells[2].FindControl("TextBox1");
TextBox DataID = (TextBox)DV_NewRoll.Rows[3].Cells[3].FindControl("TextBox2");
TextBox CallerID = (TextBox)DV_NewRoll.Rows[4].Cells[4].FindControl("TextBox3");
TextBox UserID = (TextBox)DV_NewRoll.Rows[5].Cells[5].FindControl("TextBox4");
TextBox Password = (TextBox)DV_NewRoll.Rows[6].Cells[6].FindControl("TextBox5");
TextBox Return_Status = (TextBox)DV_NewRoll.Rows[7].Cells[7].FindControl("TextBox6");


WsRollInfo.WSRoll inserts = new WsRollInfo.WSRoll();
DV_NewRoll.DataSource = inserts.InsertRoll(Convert.ToInt32(Roll_ID.Text),Roll_Data.Text, DataID.Text, Convert.ToInt32(CallerID.Text), UserID.Text, Password.Text, Convert.ToInt32(Status.Text));

BindNominal();

}

</pre>
it gave me this error: Specified argument was out of the range of valid values.
Parameter name: index


Post Your Reply Post New Question

 Viewer's Reply
DetailsView Insert New Record
Answered By Moderator1 on 6/14/2011 9:57:50 AM
Hi,

I suspect there is some in your FindControl syntax as you tried to use Rows[n], which might create issues in your code.

You can use the simple syntax as below to Find the control inside the DetailsView

TextBox txtID = (TextBox)DetailsView1.FindControl("txtID");

Try like. Hopefully, this might solve your problem.
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
Integrating Silverlight 4 with SharePoint 2010 - Free 42 Page Sample Chapter
Many .NET teams are underperforming, is yours?
The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks - Free 158 Page Preview