반응형

일단 그리드뷰에서 HyperLinkField을 하나 만드세요.  그 필드의 속성값에 원하는 다음페이지에 넘길 필드을 무제한 설정하세요 이 샘플은 3개의 값을 넘기는것입니다.


진한 부분이 속성입니다.  그 속성갑에 원하는 값을 다음과 같이 하시면 됩니다.


<asp:HyperLinkField DataNavigateUrlFields="cms_key1,cms_key2,cms_key3" DataNavigateUrlFormatString="./fa_m01.aspx?id={0}@{1}@{2}"  DataTextField="cms_name" HeaderText="     품      명    " Target="_self" >

 /asp:HyperLinkField>


받는 .CS프로 그램에서 다음과 같이 쪼게어 사용하시면 됩니다.


vCode = Request.QueryString[0]; // 전 페이지에서 넘어온 아규먼트

string[] abc = vCode.Split(new char[] { '@' });

agkey1 = abc[0];

agkey2 = abc[1];

agkey3 = abc[2];


이렇게 받아서 쓰시면 됩니다.  참고가 되면 좋겠습니다.

반응형
반응형
<%@ Page language="C#" %>

<script runat="server">

  void AuthorsGridView_RowUpdating (Object sender, GridViewUpdateEventArgs e)
  {
    // The GridView control does not automatically extract updated values

    // from TemplateField column fields. These values must be added manually

    // to the NewValues dictionary.

 
    // Get the GridViewRow object that represents the row being edited

    // from the Rows collection of the GridView control.

    int index = AuthorsGridView.EditIndex;

    GridViewRow row = AuthorsGridView.Rows[index];

   
    // Get the controls that contain the updated values. In this

    // example, the updated values are contained in the TextBox

    // controls declared in the edit item templates of each TemplateField

    // column fields in the GridView control.

    TextBox lastName = (TextBox)row.FindControl("LastNameTextBox");

    TextBox firstName = (TextBox)row.FindControl("FirstNameTextBox");

   
    // Add the updated values to the NewValues dictionary. Use the

    // parameter names declared in the parameterized update query

    // string for the key names.

    e.NewValues["au_lname"] = lastName.Text;
    e.NewValues["au_fname"] = firstName.Text;    
  }
</script>

<html>
  <body>
    <form runat="server">
      <h3>TemplateField EditItemTemplate Example</h3>
      <!-- The GridView control automatically sets the columns     -->
      <!-- specified in the datakeynames attribute as read-only.   -->
      <!-- No input controls are rendered for these columns in     -->
      <!-- edit mode.                                              -->

      <asp:gridview id="AuthorsGridView"
        datasourceid="AuthorsSqlDataSource"
        autogeneratecolumns="false"
        autogenerateeditbutton="true"
        datakeynames="au_id"
        cellpadding="10"
        onrowupdating="AuthorsGridView_RowUpdating"      
        runat="server">
               
        <columns>
          <asp:boundfield datafield="au_id"
            headertext="Author ID"
            readonly="true"/>

          <asp:templatefield headertext="Last Name"
            itemstyle-verticalalign="Top">
            <itemtemplate>
              <%#Eval("au_lname")%>
            </itemtemplate>

            <edititemtemplate>
              <asp:textbox id="LastNameTextBox"
                text='<%#Eval("au_lname")%>'
                width="90"
                runat="server"/>
              <br/>
              <asp:requiredfieldvalidator id="LastNameRequiredValidator"
                controltovalidate="LastNameTextBox"
                display="Dynamic"
                text="Please enter a last name."
                runat="server" />                                      
            </edititemtemplate>
          </asp:templatefield>

          <asp:templatefield headertext="First Name"
            itemstyle-verticalalign="Top">
            <itemtemplate>
              <%#Eval("au_fname")%>
            </itemtemplate>

            <edititemtemplate>
              <asp:textbox id="FirstNameTextBox"
                text='<%#Eval("au_fname")%>'
                width="90"
                runat="server"/>
              <br/>

              <asp:requiredfieldvalidator id="FirstNameRequiredValidator"
                controltovalidate="FirstNameTextBox"
                display="Dynamic"
                text="Please enter a first name."
                runat="server" />                      
            </edititemtemplate>
          </asp:templatefield>

          <asp:checkboxfield datafield="contract"
            headertext="Contract"
            readonly="true"/>
        </columns>
      </asp:gridview>

      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Pubs sample database.                         -->
      <asp:sqldatasource id="AuthorsSqlDataSource"  
        selectcommand="SELECT [au_id], [au_lname], [au_fname], [contract] FROM [authors]"            
        updatecommand="UPDATE authors SET au_lname=@au_lname, au_fname=@au_fname WHERE
(authors.au_id = @au_id)"
        connectionstring="server=localhost;database=pubs;integrated security=SSPI"
        runat="server">
      </asp:sqldatasource>
    </form>
  </body>
</html>
반응형

+ Recent posts