Click here to Skip to main content
15,923,142 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: HML request Pin
praveenkumar_mca23-May-07 21:16
praveenkumar_mca23-May-07 21:16 
AnswerRe: HML request Pin
Steven J Jowett23-May-07 23:20
Steven J Jowett23-May-07 23:20 
GeneralRe: HML request Pin
praveenkumar_mca24-May-07 0:29
praveenkumar_mca24-May-07 0:29 
GeneralRe: HML request Pin
Steven J Jowett24-May-07 1:25
Steven J Jowett24-May-07 1:25 
Questiondiff. between refresh and postback Pin
fgfdhghgfd23-May-07 19:21
fgfdhghgfd23-May-07 19:21 
AnswerRe: diff. between refresh and postback [modified] Pin
Sandeep Akhare23-May-07 20:48
Sandeep Akhare23-May-07 20:48 
QuestionASP.NET 2.0 C# Crystal report ,load report failed. Pin
prashesh23-May-07 19:18
prashesh23-May-07 19:18 
QuestionTrouble getting value out of a GridView cell being edited Pin
InvalidTypecast23-May-07 16:50
InvalidTypecast23-May-07 16:50 
I have a GridView on my page that I am updating in the aspx.cs file instead of the aspx page. I have been able to get the SELECTs and DELETEs working OK, but the UPDATE command is giving me problems. I tracked it down to the fact that my code is not picking up the value of the cell I edit and then Update.

For example, I have a GridView, populated from mssql, with the following columns

Product Name | Ordered | Unit Price | Total

All of the columns except for Ordered are set to read only. I have the template columns Edit and Delete. When I click Edit my template columns switch to Update and Cancel and the Ordered column's cell for the coressponding row turns into a textBox that I can type a new value in. When I click Update my page posts, but the value I typed in is not used. I think I am trying to access the value wrong. I am using Server.HtmlDecode to get the value out of the cell, but my suspicion is that it doesn't work for cells being edited. If that is the problem, what is the correct method?

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)<br />
{<br />
    GridViewRow row = GridView1.Rows[(Convert.ToInt32(e.CommandArgument))];<br />
    string productName = Server.HtmlDecode(row.Cells[0].Text);<br />
<br />
/*Various if/else if statements to catch the grid commands left out of here for brevity*/<br />
<br />
else if (e.CommandName == "Update")<br />
{<br />
    if (Session["orderIDandDate"] != null)<br />
    {<br />
        //the quantity value below isn't picking up the value in this row<br />
        //the problem is most likely here--maybe using the wrong method<br />
        quantity = Convert.ToInt32(Server.HtmlDecode(row.Cells[1].Text));<br />
<br />
        if (Convert.ToInt32(quantity) > 0)<br />
        {<br />
            SqlDataSource2.UpdateCommand = String.Format("UPDATE TABLE SET quantity = '{0}' WHERE (product = '{1}') AND (order = '{2}')", quantity, productName, orderID);<br />
            SqlDataSource2.Update();<br />
        }<br />
    }<br />
}

AnswerRe: Trouble getting value out of a GridView cell being edited Pin
InvalidTypecast23-May-07 17:21
InvalidTypecast23-May-07 17:21 
QuestionThe Session, Master Pages, and you Pin
Keith Andersch23-May-07 8:27
Keith Andersch23-May-07 8:27 
AnswerRe: The Session, Master Pages, and you Pin
Expert Coming23-May-07 16:44
Expert Coming23-May-07 16:44 
AnswerRe: Golbal.asax Pin
Vasudevan Deepak Kumar23-May-07 4:25
Vasudevan Deepak Kumar23-May-07 4:25 
QuestionNeed Some Guidance Pin
jamesmani2k523-May-07 4:11
jamesmani2k523-May-07 4:11 
AnswerRe: Need Some Guidance Pin
Vasudevan Deepak Kumar23-May-07 4:25
Vasudevan Deepak Kumar23-May-07 4:25 
QuestionConnect to database Pin
matjame23-May-07 3:35
matjame23-May-07 3:35 
AnswerRe: Connect to database Pin
Tarakeshwar Reddy23-May-07 3:52
professionalTarakeshwar Reddy23-May-07 3:52 
AnswerRe: Connect to database Pin
metallica_rock1023-May-07 23:21
metallica_rock1023-May-07 23:21 
QuestionRefreshing. Pin
Ranger4923-May-07 3:34
Ranger4923-May-07 3:34 
AnswerRe: Refreshing. Pin
kubben23-May-07 4:40
kubben23-May-07 4:40 
AnswerRe: Refreshing. Pin
Guffa23-May-07 5:32
Guffa23-May-07 5:32 
GeneralRe: Refreshing. Pin
Ranger4923-May-07 7:22
Ranger4923-May-07 7:22 
QuestionProblems using membership and roles in host system Pin
Bubbles223-May-07 2:54
Bubbles223-May-07 2:54 
QuestionTable help Pin
eric_tran23-May-07 2:05
eric_tran23-May-07 2:05 
AnswerRe: Table help Pin
kubben23-May-07 2:15
kubben23-May-07 2:15 
GeneralRe: Table help Pin
eric_tran23-May-07 2:20
eric_tran23-May-07 2:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.