Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Datagrid_ItemCommand problem

Datagrid_ItemCommand problem

Scheduled Pinned Locked Moved ASP.NET
helpcssdatabase
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rajiya
    wrote on last edited by
    #1

    I have taken a datagrid which has paging with a link button column. On click of the link button in the grid, i m passing values from the grid to another page thru session.So this is done on the datagrid_ItemCommand event. Now the problem is.............................. when i click on page number 2 of the datagrid, instead of calling the pageindex change event ....the datagrid_ItemCommand event is called...as it is the property of this event (i.e itemCommand event is the first event of the datagrid to be called before any other event of grid). Bcoz of this the values which i need to pass on the other page are not found and it gives an error saying... "Specified argument was out of the range of valid values. Parameter name: index " Can anyone tell me the way by which i can call the pageindex change event before the Itemcommand event....or any other way by which i can avoid this error...! Thanking you in anticipation. Riz

    V 1 Reply Last reply
    0
    • R Rajiya

      I have taken a datagrid which has paging with a link button column. On click of the link button in the grid, i m passing values from the grid to another page thru session.So this is done on the datagrid_ItemCommand event. Now the problem is.............................. when i click on page number 2 of the datagrid, instead of calling the pageindex change event ....the datagrid_ItemCommand event is called...as it is the property of this event (i.e itemCommand event is the first event of the datagrid to be called before any other event of grid). Bcoz of this the values which i need to pass on the other page are not found and it gives an error saying... "Specified argument was out of the range of valid values. Parameter name: index " Can anyone tell me the way by which i can call the pageindex change event before the Itemcommand event....or any other way by which i can avoid this error...! Thanking you in anticipation. Riz

      V Offline
      V Offline
      varshavmane
      wrote on last edited by
      #2

      Do u want to get the selected index??If u r using ASP.NET 1.1 version then u can use e.item.cell[0].text and u can pass this value as if (e.CommandName == "Select") { Response.Redirect("../FolderName/PageName.aspx?Caption=" + e.Item.Cells[0].Text); } If 2.0 version then use datakeys. U dont need to use session here. Hope I have understood ur problem??

      R V 3 Replies Last reply
      0
      • V varshavmane

        Do u want to get the selected index??If u r using ASP.NET 1.1 version then u can use e.item.cell[0].text and u can pass this value as if (e.CommandName == "Select") { Response.Redirect("../FolderName/PageName.aspx?Caption=" + e.Item.Cells[0].Text); } If 2.0 version then use datakeys. U dont need to use session here. Hope I have understood ur problem??

        R Offline
        R Offline
        Rajiya
        wrote on last edited by
        #3

        What u said is fine but my problem is not that. My problem is with paging in the datagrid. when i click on page number 2 of the datagrid, instead of calling the pageindex change event ....the datagrid_ItemCommand event is called...as it is the property of this event (i.e itemCommand event is the first event of the datagrid to be called before any other event of grid). Bcoz of this the values which i need to pass on the other page are not found and it gives an error saying... "Specified argument was out of the range of valid values. Parameter name: index " Am pasting the code Private Sub dgrSop_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgrSop.ItemCommand dgrSop.CurrentPageIndex = 0 dgrSop.EditItemIndex = e.Item.ItemIndex Dim id As Integer Dim fName As String Dim sId As String sId = e.Item.Cells(0).Text fName = e.Item.Cells(6).Text Session("FName") = fName If e.CommandName = "SopEdit" Or e.CommandName = "Del" Then 'id = dgrSop.DataKeys(e.Item.ItemIndex) Select Case e.CommandName Case "SopEdit" Response.Redirect("FrmEditSop.aspx?SopID=" & sId) Case "Del" Dim cmddel As SqlCommand = New SqlCommand("ProcDelSOP", ConDel.Connection(Application("ipath"))) cmddel.CommandType = CommandType.StoredProcedure cmddel.Parameters.Add("@SOPID", id) cmddel.ExecuteNonQuery() End Sub Paging fails here. Riz

        _ 1 Reply Last reply
        0
        • R Rajiya

          What u said is fine but my problem is not that. My problem is with paging in the datagrid. when i click on page number 2 of the datagrid, instead of calling the pageindex change event ....the datagrid_ItemCommand event is called...as it is the property of this event (i.e itemCommand event is the first event of the datagrid to be called before any other event of grid). Bcoz of this the values which i need to pass on the other page are not found and it gives an error saying... "Specified argument was out of the range of valid values. Parameter name: index " Am pasting the code Private Sub dgrSop_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgrSop.ItemCommand dgrSop.CurrentPageIndex = 0 dgrSop.EditItemIndex = e.Item.ItemIndex Dim id As Integer Dim fName As String Dim sId As String sId = e.Item.Cells(0).Text fName = e.Item.Cells(6).Text Session("FName") = fName If e.CommandName = "SopEdit" Or e.CommandName = "Del" Then 'id = dgrSop.DataKeys(e.Item.ItemIndex) Select Case e.CommandName Case "SopEdit" Response.Redirect("FrmEditSop.aspx?SopID=" & sId) Case "Del" Dim cmddel As SqlCommand = New SqlCommand("ProcDelSOP", ConDel.Connection(Application("ipath"))) cmddel.CommandType = CommandType.StoredProcedure cmddel.Parameters.Add("@SOPID", id) cmddel.ExecuteNonQuery() End Sub Paging fails here. Riz

          _ Offline
          _ Offline
          _AK_
          wrote on last edited by
          #4

          Have you defined the correct method name in the HTML part of the datagrid in case of OnPageIndexChanged?

          Best Regards, Apurva Kaushal

          1 Reply Last reply
          0
          • V varshavmane

            Do u want to get the selected index??If u r using ASP.NET 1.1 version then u can use e.item.cell[0].text and u can pass this value as if (e.CommandName == "Select") { Response.Redirect("../FolderName/PageName.aspx?Caption=" + e.Item.Cells[0].Text); } If 2.0 version then use datakeys. U dont need to use session here. Hope I have understood ur problem??

            V Offline
            V Offline
            vengaqua
            wrote on last edited by
            #5

            What is "e" in this command

            Mohinder Singh

            1 Reply Last reply
            0
            • V varshavmane

              Do u want to get the selected index??If u r using ASP.NET 1.1 version then u can use e.item.cell[0].text and u can pass this value as if (e.CommandName == "Select") { Response.Redirect("../FolderName/PageName.aspx?Caption=" + e.Item.Cells[0].Text); } If 2.0 version then use datakeys. U dont need to use session here. Hope I have understood ur problem??

              V Offline
              V Offline
              vengaqua
              wrote on last edited by
              #6

              hi dear i am using asp.net 1.1. i want to combine three fields that i am getting from stored procedure and want the cell to be hyperlink.and when i click i want to pass this as varible in response.redirect tag.How to do it please tell me i need this very urgently. Thanks in advance Regards

              Mohinder Singh

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups