I have a table in which the first column is that of LinkButtons. The problem is that when the user clicks on one of the LinkButtons, it makes that little "postback click", but that's it. It's only on the *second* click it actually executes the appropriate procedure.
Here's the code for the redirect sub (the LinkButton of interest is "select" with method "BindDetailGrid":[tt]
Sub DataGrid_Select(Sender As Object, E As datagridcommandEventArgs)
trace.warn("enter DataGrid_Select - command name ="
trace.warn(e.commandname)
select case e.commandname
case "select"
BindDetailGrid(e)
case "select_pi"
bindPIgrid(e)
case "grants_in_01"
grants_in(e,"I",2001)
case "grants_all_01"
grants_in(e,"%",2001)
case "grants_in_02"
grants_in(e,"I",2002)
case "grants_all_02"
grants_in(e,"%",2002)
end select
End Sub
[/tt]
and here is the sub "BindDetailGrid":[tt]
Sub BindDetailGrid(e)
trace.warn("enter BindDetailGrid"
'trace.warn("DataGrid1.SelectedIndex=" & cstr(e.item.itemIndex))
if LastOrg = String.Empty then
lastOrg=CStr(DataGrid1.DataKeys(e.item.itemIndex)).Replace("'", "''"
DetailsGrid.CurrentPageIndex = 0
else
if LastOrg <> CStr(DataGrid1.DataKeys(e.item.itemIndex)).Replace("'", "''" then
lastOrg=CStr(DataGrid1.DataKeys(e.item.itemIndex)).Replace("'", "''"
DetailsGrid.CurrentPageIndex = 0
end if
end if
trace.warn("LastOrg="+lastorg)
trace.warn("selected index = "+cstr(DataGrid1.SelectedIndex))
' get the filter value from the master Grid's DataKeys collection
If DataGrid1.SelectedIndex <> -1 Then
org_name.text=LastOrg
org_name.visible=true
DetailsGrid.visible=true
ShowOrg.visible=true
DataGrid1.visible=false
in_state.visible = false
in_org.visible=false
org_lbl.visible=false
st_lbl.visible=false
go_button.visible=false
Dim ConnectionString As String = ConfigurationSettings.AppSettings("ConnectstrW"
Dim filterValue As String = LastOrg
Dim CommandText As String
If SortField2 = String.Empty Then
CommandText = "select grant_yr,grant_title,Grant_#,grant_amt,decision,pi_first_nm,pi_last_nm from grant_info where org_id = '" & filterValue & "' order by decision, grant_amt desc"
else
CommandText = "select grant_yr,grant_title,Grant_#,grant_amt,decision,pi_first_nm,pi_last_nm from grant_info where org_id = '" & filterValue & "' order by " & SortField2
if sortasc="NO" then
CommandText += " DESC"
end if
end if
trace.warn(" BindDetailGrid CommandText=" & cstr(CommandText))
Dim myConnection As New SqlConnection(ConnectionString)
Dim myCommand As New SqlDataAdapter(CommandText, myConnection)
dim ds2 as New DataSet()
myCommand.Fill(ds2)
DetailsGrid.DataSource = ds2
DetailsGrid.DataBind()
End If
End Sub
[/tt]
Thanks very much!
RebLazer
Here's the code for the redirect sub (the LinkButton of interest is "select" with method "BindDetailGrid":[tt]
Sub DataGrid_Select(Sender As Object, E As datagridcommandEventArgs)
trace.warn("enter DataGrid_Select - command name ="
trace.warn(e.commandname)
select case e.commandname
case "select"
BindDetailGrid(e)
case "select_pi"
bindPIgrid(e)
case "grants_in_01"
grants_in(e,"I",2001)
case "grants_all_01"
grants_in(e,"%",2001)
case "grants_in_02"
grants_in(e,"I",2002)
case "grants_all_02"
grants_in(e,"%",2002)
end select
End Sub
[/tt]
and here is the sub "BindDetailGrid":[tt]
Sub BindDetailGrid(e)
trace.warn("enter BindDetailGrid"
'trace.warn("DataGrid1.SelectedIndex=" & cstr(e.item.itemIndex))
if LastOrg = String.Empty then
lastOrg=CStr(DataGrid1.DataKeys(e.item.itemIndex)).Replace("'", "''"
DetailsGrid.CurrentPageIndex = 0
else
if LastOrg <> CStr(DataGrid1.DataKeys(e.item.itemIndex)).Replace("'", "''" then
lastOrg=CStr(DataGrid1.DataKeys(e.item.itemIndex)).Replace("'", "''"
DetailsGrid.CurrentPageIndex = 0
end if
end if
trace.warn("LastOrg="+lastorg)
trace.warn("selected index = "+cstr(DataGrid1.SelectedIndex))
' get the filter value from the master Grid's DataKeys collection
If DataGrid1.SelectedIndex <> -1 Then
org_name.text=LastOrg
org_name.visible=true
DetailsGrid.visible=true
ShowOrg.visible=true
DataGrid1.visible=false
in_state.visible = false
in_org.visible=false
org_lbl.visible=false
st_lbl.visible=false
go_button.visible=false
Dim ConnectionString As String = ConfigurationSettings.AppSettings("ConnectstrW"
Dim filterValue As String = LastOrg
Dim CommandText As String
If SortField2 = String.Empty Then
CommandText = "select grant_yr,grant_title,Grant_#,grant_amt,decision,pi_first_nm,pi_last_nm from grant_info where org_id = '" & filterValue & "' order by decision, grant_amt desc"
else
CommandText = "select grant_yr,grant_title,Grant_#,grant_amt,decision,pi_first_nm,pi_last_nm from grant_info where org_id = '" & filterValue & "' order by " & SortField2
if sortasc="NO" then
CommandText += " DESC"
end if
end if
trace.warn(" BindDetailGrid CommandText=" & cstr(CommandText))
Dim myConnection As New SqlConnection(ConnectionString)
Dim myCommand As New SqlDataAdapter(CommandText, myConnection)
dim ds2 as New DataSet()
myCommand.Fill(ds2)
DetailsGrid.DataSource = ds2
DetailsGrid.DataBind()
End If
End Sub
[/tt]
Thanks very much!
RebLazer