Datagrid_ItemCommand problem
-
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
-
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
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??
-
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??
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
-
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
-
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??
-
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??
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