It's hard to tell from your snippets, because odd are the problem is
in your page load code, which you haven't posted.

this usually happens when the grid is not bound when the page is
reloaded.  Remember each call to the server causes the page to be
reloaded.  It appears that your even includes a call to rebind the
code, so perhaps it is not firing at all.

Have you tried stepping through the code to make sure the event is
firing properly?

Post your page_load event so we can see if there is something odd in there.


On 8/7/05, DD <[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> I have a datagrid that queries data on two fields, UserID and
> ScenarioID.  It displays the data fine, but when I click the update
> button no data is displayed.
> 
> Snippets of my code:
> 
> Sub BindData()
>                 dim objConn as new OleDbConnection
> ("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\DSS\DSS.mdb")
>                 objConn.Open()
>                 Dim ScenID As String = Request.QueryString("ScenID")
>                 Dim ProjID As String = Request.QueryString("ProjID")
>         Dim UserID as Integer = CStr(Request.Params("UserID"))
>                 Dim strSQL as String = "SELECT tblScenCrit.CriteriaID,
> tblScenCrit.WeightID, tblScenCrit.UserID, tblScenCrit.ScenarioID,
> tblWeighting.Weighting, tblCriteria.Name, tblCriteria.Description FROM
> tblCriteria INNER JOIN (tblWeighting INNER JOIN tblScenCrit ON
> tblWeighting.WeightID = tblScenCrit.WeightID) ON
> tblCriteria.CriteriaID = tblScenCrit.CriteriaID WHERE UserID =" &
> Session(UserID) & " and ScenarioID = '" & (Context.Items("ScenID")) &
> "'"
>                 Dim objCmd as New OleDbCommand(strSQL, objConn)
>                 dgCrit.DataSource =
> objCmd.ExecuteReader(CommandBehavior.CloseConnection)
>                 dgCrit.DataBind()
>                 objConn.Close()
>     End Sub
> 
> and.....
> 
> Sub dgCrit_Update(sender As Object, e As DataGridCommandEventArgs)
>                 Dim ScenID As String = Request.QueryString("ScenID")
>                 Dim UserID As Integer = CStr(Request.Params("UserID"))
> 
>                 Dim strCriteriaID as String = e.Item.Cells(1).Text
>                 Dim strName as String = e.Item.Cells(2).Text
>                 Dim strDescription as String = e.Item.Cells(3).Text
>                 Dim strScenarioID as String = e.Item.Cells(4).Text
>                 Dim strUserID as String = e.Item.Cells(5).Text
>                 Dim strWeightID as String = 
> CType(e.Item.FindControl("ddlWeight"),
> DropDownList).SelectedItem.Value
> 
>                 ' Dim strSQL as String =        "UPDATE [tblScenCrit] SET 
> [WeightID] =
> @WeightID WHERE [CriteriaID] = @CriteriaID"
>                 Dim strSQL as String = " UPDATE tblScenCrit SET 
> tblScenCrit.WeightID
> = [EMAIL PROTECTED] WHERE (((tblScenCrit.ScenarioID)[EMAIL PROTECTED]) AND
> ((tblScenCrit.UserID)[EMAIL PROTECTED]) AND
> ((tblScenCrit.CriteriaID)[EMAIL PROTECTED]))"
> 
> 
> 
>                 dim objConn as new OleDbConnection
> ("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\DSS\DSS.mdb")
>                 objConn.Open()
>                 Dim myCommand as OleDbCommand = new OleDbCommand(strSQL, 
> objConn)
>                 myCommand.CommandType = CommandType.Text
> 
>                 Dim parameterWeightID as OleDbParameter = new
> OleDbParameter("@WeightID", OleDbType.Char)
>                 parameterWeightID.Value = strWeightID
>                 myCommand.Parameters.Add(parameterWeightID)
> 
>                 Dim parameterCriteriaID as OleDbParameter = new
> OleDbParameter("@CriteriaID", OleDbType.Char)
>                 parameterCriteriaID.Value = strCriteriaID
>                 myCommand.Parameters.Add(parameterCriteriaID)
> 
>                 Dim parameterName as OleDbParameter = new 
> OleDbParameter("@Name",
> OleDbType.Char)
>                 parameterName.Value = strName
>                 myCommand.Parameters.Add(parameterName)
> 
>                 Dim parameterDescription as OleDbParameter = new
> OleDbParameter("@Description", OleDbType.Char)
>                 parameterDescription.Value = strDescription
>                 myCommand.Parameters.Add(parameterDescription)
> 
>                 Dim parameterScenarioID as OleDbParameter = new
> OleDbParameter("@ScenarioID", OleDbType.Char)
>                 parameterScenarioID.Value = strScenarioID
>                 myCommand.Parameters.Add(parameterScenarioID)
> 
>                 Dim parameterUserID as OleDbParameter = new
> OleDbParameter("@UserID", OleDbType.Char)
>                 parameterUserID.Value = strUserID
>                 myCommand.Parameters.Add(parameterUserID)
> 
> 
> 
>                 myCommand.ExecuteNonQuery()
>                 objConn.Close()
> 
>                 dgCrit.EditItemIndex = -1
>                 BindData()
>     End Sub
> 
>     Function GetWeight() as DataSet
>                 Dim objConn as New OleDbConnection
> ("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\DSS\DSS.mdb")
>                 Dim objCmd as New OleDbDataAdapter("SELECT WeightID, 
> Weighting from
> tblWeighting ORDER BY Weighting", objConn)
>                 Dim ddlDataSet as DataSet = New DataSet()
>                 objCmd.Fill(ddlDataSet, "ddlWeight")
>                 Return ddlDataSet
>         End Function
> 
> and....
> 
> <asp:DataGrid id="dgCrit" runat="server"
>             AutoGenerateColumns="False" CellPadding="4"
>             HeaderStyle-BackColor="#0000bf"
>             HeaderStyle-ForeColor="White"
>             HeaderStyle-HorizontalAlign="Center"
>             HeaderStyle-Font-Bold="True"
>             EditItemStyle-BackColor="#ccccee"
>             OnEditCommand="dgCrit_Edit"
>             OnUpdateCommand="dgCrit_Update"
>             OnCancelCommand="dgCrit_Cancel"
>             DataKeyField="CriteriaID">
> 
>             <Columns>
>                 <asp:EditCommandColumn EditText="Add Weights"
> ButtonType="PushButton"
>                 UpdateText="Update" CancelText="Cancel" />
> 
>                 <asp:BoundColumn HeaderText="Criteria ID"
> DataField="CriteriaID" ReadOnly="True" />
> 
>                 <asp:BoundColumn HeaderText="Name" DataField="Name"
> ReadOnly="True" />
>                 <asp:BoundColumn HeaderText="Description"
> DataField="Description" ReadOnly="True" />
>                 <asp:BoundColumn HeaderText="ScenarioID"
> DataField="ScenarioID" ReadOnly="True" />
>                 <asp:BoundColumn HeaderText="UserID"
> DataField="UserID" ReadOnly="True" />
>                 <asp:TemplateColumn HeaderText="Weight">
>                                         <ItemTemplate>
>                                                 <%# 
> DataBinder.Eval(Container.DataItem, "Weighting") %>
>                                         </ItemTemplate>
>                                         <EditItemTemplate>
>                                                 <asp:DropDownList 
> runat="server" id="ddlWeight"
> DataValueField="WeightID" DataTextField="Weighting" DataSource="<%#
> GetWeight() %>" />
>                                         </EditItemTemplate>
>                                 </asp:TemplateColumn>
>              </columns>
>         </asp:DataGrid>
> 
> Whats wrong with the code?!?
> 
> Thanks
> 
> DJ
> 
> 
> 
> 
> 
> 
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
> 


-- 
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com


------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12hk8jlvr/M=362131.6882499.7825260.1510227/D=groups/S=1705006764:TM/Y=YAHOO/EXP=1123474795/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life 
- brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to