Question : asp.net I have a gridview that is updatedable. what I would like to do is pass its -> ID value to another page that would allow the user to update picture images for that user ID.

I have a gridview that is updatedable. what I would like to do is pass its -> ID value to another page that would allow the user to update picture images for that user ID.
 th operation would give the user the oppurity to update the GridView and then link to another routine on a diffent page titled UpdatePicture.

Need to know how to do a querystring that select the page and then pass its Id value to the codebehind of that page.

 nonqueryCommand.CommandText = "Select ID FROM Equipment WHERE Equipment.ID = (SELECT (Equipment.ID) FROM Equipment where id? = '" + Request.QueryString("id") + "')"
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
<%@ Page Language="VB" Debug="true" MasterPageFile="~/Nested Master Pages/user.master" Title="Untitled Page"  %>
<%@ Register Assembly="RbmControls" Namespace="RbmControls" TagPrefix="Rbm" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
    
    Public Sub Page_Load()
        currentUser = Membership.GetUser()
        SqlDataSource1.SelectParameters("UserId").DefaultValue = currentUser.ProviderUserKey.ToString()
        SqlDataSource1.DataBind()
    End Sub

    Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        'If Cancel button is clicked, send user to Default
        Response.Redirect("~/Annonymous/index.aspx")
    End Sub

    Dim currentUser As MembershipUser
    'SelectCommand="SELECT ID, UserId, Year, Make, Model, Type, MilesHours, VinSerial, Description, Location, Price,  FROM Equipment, CustomerImages Where UserId = @UserId"
</script>

<%-- Add content controls here --%>

<asp:Content ID="Content2" runat="server" contentplaceholderid="ContentPlaceHolder4">
Welcome: <b><%=currentUser.UserName%></b>.<br />
UserId: <b><%=currentUser.ProviderUserKey%></b>.
<div>

      <asp:GridView ID="GridView2" AllowSorting="true" AllowPaging="true" Runat="server" Font-Size="Small"
        DataSourceID="SqlDataSource1" AutoGenerateEditButton="true" AutoGenerateDeleteButton="True" DataKeyNames="Id"    
        AutoGenerateColumns="False">

        <Columns>
          <asp:BoundField HeaderText=" ID " DataField="ID" SortExpression="ID" ReadOnly="true" ControlStyle-Width="20" />
          <asp:BoundField HeaderText=" Year " DataField="Year" SortExpression="Year" ItemStyle-HorizontalAlign="Center" ControlStyle-Width="30" />
          <asp:BoundField HeaderText=" Make " DataField="Make" SortExpression="Make" ControlStyle-Width="150" />
          <asp:BoundField HeaderText=" Model " DataField="Model" SortExpression="Model" ControlStyle-Width="80" />
          <asp:BoundField HeaderText=" Type " DataField="Type" SortExpression="Type" ControlStyle-Width="150" />
          <asp:BoundField HeaderText=" MilesHours " DataField="MilesHours" SortExpression="MilesHours"   ItemStyle-HorizontalAlign="Right" ControlStyle-Width="60" />
          <asp:BoundField HeaderText=" VinSerial " DataField="VinSerial" SortExpression="VinSerial" ItemStyle-HorizontalAlign="Center" ControlStyle-Width="60" />
          <asp:BoundField HeaderText=" Description " DataField="Description" SortExpression="Description" ControlStyle-Width="200" />
          <asp:BoundField HeaderText=" Location " DataField="Location" SortExpression="Location" ControlStyle-Width="200"/>
          <asp:BoundField HeaderText=" Price " DataField="Price" SortExpression="Price" DataFormatString="${0:C}" ItemStyle-HorizontalAlign="Right" ControlStyle-Width="50"/>
      
Can I put a link querystring to pass this view of the grid's ID to another page.
           
          </Columns>
      </asp:GridView>
      
    </asp:Content>

Answer : asp.net I have a gridview that is updatedable. what I would like to do is pass its -> ID value to another page that would allow the user to update picture images for that user ID.

1. change your select statement, this is really vunerable for sql injection.

2. You can make a TemplateField instead of a BoundField. From there you can use <%# Eval("name of your datafield") %> in order to get the information you need.
Random Solutions  
 
programming4us programming4us