Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello all

In my project i used datalist. Where i used the textrea to put the review at the time of rating but how will i find the particular textarea in the particular row of the datalist and insert to database.

My code is
C#
string ratedto = ((Button)sender).CommandArgument;
              datacontex db = new datacontex ();
             getuser uid = (getuser )Session["userlogin"];
             int userid = ud.UserID ;
             int recCount = db.Starratings.Count(rate => rate.RatingBy ==userid & rate.UserID ==Convert .ToInt16 (ratedto ));
             if (recCount <= 0)
             {

           //save data to database;

But i want to also find the textarea value of particular row of datalist to insert to database.

Is it correct way to find teatarea of the selected row of datalist?

C#
for (int i = 0; i < Datalist1.Items.Count; i++)
       {
           HtmlInputText currentTextbox = (HtmlInputText)Datalist1.Items[i].FindControl("txtName");
           HtmlTextArea currentTextArea = (HtmlTextArea)Datalist1.Items[i].FindControl("txtDesc");

           string texboxValue= currentTextbox.Value; //Get the textboxvalue
           string textareaValue=currentTextArea.Value; //Get the textareavalue
       }


But it is not working. It inserted data as the row present in datalist. Anybody know the solution

Thanks in advance.
Posted
Updated 22-Jan-11 5:51am
v4
Comments
TweakBird 22-Jan-11 1:55am    
Edited for Code blocks.
thatraja 22-Jan-11 2:10am    
what's the error message? include that in your question
Ankur\m/ 22-Jan-11 2:23am    
Starlene wrote:
But i want to also find the textarea value of particular row of datalist to insert to database. Is it correct way to find textarea of the selected row of datalist? this the question
Ankur\m/ 22-Jan-11 2:24am    
Mover over a particular comment, there is a 'Reply' link. Use it to reply to that comment. Otherwise the notifications are not sent.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900