Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ItemCommand

Status
Not open for further replies.

JoeZim

MIS
Sep 11, 2003
87
US
I've been looking at many posts in the forum and feel like I've followed the suggestions properly, but I can't get it working.

I've setup a linkbutton in my grid. When the user clicks the linkbutton, I would like the value in column 2 to be picked up and used as a parameter for another grid. This other grid will reside an a new page, so once the parameter value is set, the new page should load. Here is my code:

Code:
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here

        Panel1.Controls.Add(Me.LoadControl("Banner.ascx"))
        Panel2.Controls.Add(Me.LoadControl("Left.ascx"))

        Dim cf As New MandT.CLD.Inquiry.BusinessTier.BLL

        CustomerSearchDataSet = cf.GetCustomerFilterDataSet(Session("search1"), Session("search2"), Session("search3"), Session("search4"), Session("search5"))
        ResultGrid.DataSource = CustomerSearchDataSet
        ResultGrid.DataBind()

    End Sub

    Private Sub ResultGrid_PageIndexChanged(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs)
        ResultGrid.CurrentPageIndex = e.NewPageIndex
        ' If the grid is sorted, reapply the sort expression here.
        ResultGrid.DataBind()
    End Sub

    Private Sub ResultGrid_ItemCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)

        If e.CommandName = "GetObligor" Then
            Session("Obligor") = e.Item.Cells(1).Text
            Server.Transfer("SearchDetails.aspx")
        End If

    End Sub

I'm not sure why my ItemCommand code won't fire. Is the Page_Load datagrid bind code causing my problems?



 
Sorry, forgot the html:

Code:
			<asp:datagrid id="ResultGrid" runat="server" Width="632px" AutoGenerateColumns="False" PageSize="20" AllowPaging="True">

				<Columns>
					<asp:ButtonColumn Text="Select" CommandName="GetObligor"></asp:ButtonColumn>
					<asp:BoundColumn DataField="OBLIGOR" HeaderText="Obligor"></asp:BoundColumn>
					<asp:BoundColumn DataField="ad051_alt" HeaderText="Name"></asp:BoundColumn>
				</Columns>

			</asp:datagrid>
 
I'm not sure why my ItemCommand code won't fire
It hasn't got a Handles event attached to it so the DataGrid doens't know that it's supposed to fire that event.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks ca8msm, I would not have caught the most obvious. Sorry about that. TGIF...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top