Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

This is assuming you have an EditCommandColumn in your datagrid, each link button will trigger one of these subs. In each sub you get the key field you specify in your datagrid but using the ItemIndex.

   Private Sub Datagrid1_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles Datagrid1.CancelCommand
      'Cancel command
     Datagrid1.EditItemIndex = -1
   End Sub

   Private Sub Datagrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles Datagrid1.UpdateCommand
       'Update command
      Dim ProductID As Integer = Datagrid1.DataKeys(e.Item.ItemIndex)
   End Sub

   Private Sub Datagrid1_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles Datagrid1.DeleteCommand
       'Delete command
      Dim ProductID As Integer = Datagrid1.DataKeys(e.Item.ItemIndex)
   End Sub

Posted
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       SqlDataAdapter1.SelectCommand.Parameters("@LeadID").Value = intLeadid
       SqlDataAdapter1.Fill(DsNegotiable1)
       DataGrid1.DataBind()
   End Sub

   Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.EditCommand
       DataGrid1.EditItemIndex = e.Item.ItemIndex
       DataGrid1.DataBind()
   End Sub

   Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand
       SqlDataAdapter1.Update(DsNegotiable1)
       DsNegotiable1.Clear()
       DataGrid1.DataBind()
   End Sub

Posted
Do you need to load your databind in your page_load every time? Check for IsPostBack first, also, how do you know its not getting to your Updatecommand, are you doing anytype of debug message to see if it gets there?
Posted
			<asp:datagrid id=DataGrid1 runat="server" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="3" GridLines="Vertical" DataSource="<%# DsNegotiable1 %>" AutoGenerateColumns="False" DataMember="UnsecuredDebts">
			<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#008A8C"></SelectedItemStyle>
			<AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>
			<ItemStyle ForeColor="Black" BackColor="#EEEEEE"></ItemStyle>
			<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#000084"></HeaderStyle>
			<FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle>
			<Columns>
				<asp:BoundColumn DataField="CreditorName" SortExpression="CreditorName"></asp:BoundColumn>
				<asp:BoundColumn DataField="Code" SortExpression="Code" HeaderText="Code"></asp:BoundColumn>
				<asp:BoundColumn DataField="UnsecuredBalOwed" SortExpression="UnsecuredBalOwed" HeaderText="UnsecuredBalOwed"></asp:BoundColumn>
				<asp:BoundColumn DataField="UnsecuredPctRate" SortExpression="UnsecuredPctRate" HeaderText="UnsecuredPctRate"></asp:BoundColumn>
				<asp:BoundColumn DataField="UnsecuredLastPymtDate" SortExpression="UnsecuredLastPymtDate" HeaderText="UnsecuredLastPymtDate"></asp:BoundColumn>
				<asp:BoundColumn DataField="UnsecuredMinMoPymt" SortExpression="UnsecuredMinMoPymt" HeaderText="UnsecuredMinMoPymt"></asp:BoundColumn>
				<asp:ButtonColumn Text="Delete" ButtonType="PushButton" CommandName="Delete"></asp:ButtonColumn>
				<asp:EditCommandColumn ButtonType="PushButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
			</Columns>
			<PagerStyle HorizontalAlign="Center" ForeColor="Black" BackColor="#999999" Mode="NumericPages"></PagerStyle>
		</asp:datagrid>

Posted

¿Don't you have to add this to your datagrid definition?

<asp:datagrid id=DataGrid1 runat="server" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="3" GridLines="Vertical" DataSource="<%# DsNegotiable1 %>" AutoGenerateColumns="False" DataMember="UnsecuredDebts" OnUpdateCommand="DataGrid1_UpdateCommand">

 

And OnCancelCommand, etc, etc.....

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...