View Full Version : GridView Control
annbransom
08-31-2006, 01:08 AM
Thanks for the reply. But what I'm asking is once I am writing the code behind the GridViewControl, what do I put so that I can use the text from the grid in a redirect. I.E.
If e.CommandName = "Select" Then
Response.Redirect("OhioRentalAdmin.aspx?Veh=" & Text from the first column of the GridView)
End IF
How do I get the text from the first column of the GridView and place it in this code?
annbransom
08-31-2006, 02:16 AM
I have a gridview control that I am trying towrite a selectindexchanged event for. All I want is that when you click on the VanNumber buttonfield, it redirects you to a page with a query string parmeter ?Veh= and whatever the van number is. Right now, it is just dumping in a null value. Any suggestions? Here is the gridview code:
<asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" PageSize="100" Width="520px" DataKeyNames="VanNumber" DataMember="VanNumber">
<Columns>
<asp:ButtonField CommandName="Select" DataTextField="VanNumber" Text="Button" HeaderText="Veh#" />
<asp:BoundField DataField="VanMake" HeaderText="Make" />
<asp:BoundField DataField="VanModel" HeaderText="Model" />
<asp:BoundField DataField="VanSize" HeaderText="Size" />
<asp:BoundField DataField="Location" HeaderText="Location" />
<asp:CheckBoxField DataField="HandControls" HeaderText="Hand Controls?" />
<asp:CheckBoxField DataField="TransferSeat" HeaderText="Transfer Seat?" />
<asp:BoundField DataField="StartDate" DataFormatString="{0:d}" HeaderText="Next Rental Begins" HtmlEncode="False" />
</Columns>
<RowStyle Font-Names="Arial" Font-Size="10pt" />
<AlternatingRowStyle BackColor="#C0FFC0" Font-Names="Arial" Font-Size="10pt" />
</asp:GridView>
vvsharma
08-31-2006, 03:12 AM
Since you want touse a button instead of LinkButton you can do something use
<asp:gridview id="CustomersGridView" datasourceid="CustomersSqlDataSource" onrowcommand="some_function_name_in_your_codebehind" ...
<columns>
<asp:buttonfield buttontype="Button"commandname="Select"headertext="Select Customer"text="Select"/>
</columns>
and in your codebehind have something like...
Sub some_function_name_in_your_codebehind(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
If e.CommandName = "Select" Then....
See http://msconline.maconstate.edu/tutorials/ASPNET2/ASPNET09/aspnet09-05.aspx,if you want to use a linkbutton.
Vikram
DiscountASP.NET
www.DiscountASP.NET (http://www.discountasp.net/)
vvsharma
08-31-2006, 06:29 AM
Well to get the text from the first column you need to do have' e.Item.Cells[0] '
Vikram
DiscountASP.NET
www.DiscountASP.NET (http://www.discountasp.net/)
vBulletin® ©Jelsoft Enterprises Ltd.