narmi2
asked on
Datagrid (OnSelectedIndexChanged) Problem
Hi
I have a link button which says:
<asp:LinkButton id="lbQuote" runat="server" commandname="select">Quote </asp:Link Button>
I have a datagrid which says:
onSelectedIndexChanged="ge tSelected"
And in code behind it says:
Sub getQuoted(ByVal src As Object, ByVal e As EventArgs)
response.redirect("page1.a spx?id=" & DataGrid1.DataKeys(DataGri d1.Selecte dIndex).To String)
End Sub
What I need now is another link button, next to the existing link button which does something different depending on the row in the datagrid it is in...
For example
Sub getReported(ByVal src As Object, ByVal e As EventArgs)
response.redirect("page2.a spx?id=" & DataGrid1.DataKeys(DataGri d1.Selecte dIndex).To String)
End Sub
How would I go about doing that?
I have a link button which says:
<asp:LinkButton id="lbQuote" runat="server" commandname="select">Quote
I have a datagrid which says:
onSelectedIndexChanged="ge
And in code behind it says:
Sub getQuoted(ByVal src As Object, ByVal e As EventArgs)
response.redirect("page1.a
End Sub
What I need now is another link button, next to the existing link button which does something different depending on the row in the datagrid it is in...
For example
Sub getReported(ByVal src As Object, ByVal e As EventArgs)
response.redirect("page2.a
End Sub
How would I go about doing that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
I now have this
Dim clickedButton As LinkButton = CType(src, LinkButton)
If clickedButton.CommandArgum ent = "caQuoted" Then
Response.Redirect("reply.a spx?t=" & CInt(Request.QueryString(" t")) & "&p=" & DataGrid1.DataKeys(DataGri d1.Selecte dIndex).To String)
Else
Response.Redirect("report. aspx?t=" & CInt(Request.QueryString(" t")) & "&p=" & DataGrid1.DataKeys(DataGri d1.Selecte dIndex).To String)
End If
and it says:
Specified cast is not valid
when I click one or any of the 2 linkbuttons.
I now have this
Dim clickedButton As LinkButton = CType(src, LinkButton)
If clickedButton.CommandArgum
Response.Redirect("reply.a
Else
Response.Redirect("report.
End If
and it says:
Specified cast is not valid
when I click one or any of the 2 linkbuttons.
I think I was wrong
You have to use no the onSelectedIndexChanged of the grid but the onclick events of the button
on other hand hte sabeesh solution looks more nice and clear
Martin
You have to use no the onSelectedIndexChanged of the grid but the onclick events of the button
on other hand hte sabeesh solution looks more nice and clear
Martin
just add the CommandArgument property and assing a value to it
also do the same for the lbQuote
assign both to the getSelected event
and before call Response.Redirect check the value of the
Dim clickedButton as LinkButton = CType(src, LinkButton)
if clickedButton.CommandArgum
.....
Regards,
Martin