datagrid-passing-parameters-problem.html

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • preeti13
    New Member
    • Aug 2007
    • 67

    datagrid-passing-parameters-problem.html

    I have a datagrid with a hyperlink field. It passes a parameter but I need
    it to pass two. I need two of the parameters to be querystrings but I have no idea how to add them the hyperlink column if any one know about this then please help me .
    here is my code:

    [HTML]
    <asp:datagrid id="DataGrid1" runat="server" AutoGenerateCol umns="False" AlternatingItem Style-BorderStyle="Do tted" BorderColor="Bl ack" BorderStyle="So lid" Width="650px">
    <AlternatingIte mStyle BorderStyle="Do tted"></AlternatingItem Style>
    <Columns>
    <asp:BoundColum n DataField="Nomi natedByfirstnam e" HeaderText="Nom inated By First name">
    <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
    </asp:BoundColumn >
    <asp:BoundColum n DataField="Nomi natedByLastName " HeaderText="Nom inated By Last Name">
    <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
    </asp:BoundColumn >
    <asp:BoundColum n DataField="Nomi neefirstName" HeaderText="Nom inee First Name">
    <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
    </asp:BoundColumn >
    <asp:BoundColum n DataField="Nomi neeLastName" HeaderText="Nom inee Last Name">
    <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
    </asp:BoundColumn >
    <asp:BoundColum n DataField="Nomi neeDept" HeaderText="Nom inee Dept">
    <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
    </asp:BoundColumn >
    <asp:BoundColum n DataField="Date Created" HeaderText="Dat e Created">
    <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
    </asp:BoundColumn >
    <asp:HyperLinkC olumn Text="Detail" HeaderStyle-BackColor="#316 AC5" HeaderText="Det ail" HeaderStyle-ForeColor="Whit e" HeaderStyle-Font-Bold="True" DataNavigateUrl Field="employee nominationid" DataNavigateUrl FormatString="R easonfornominat ing.aspx?employ eenominationid= {0}"></asp:HyperLinkCo lumn>

    </Columns>
    </asp:datagrid>

    [/HTML]
  • nateraaaa
    Recognized Expert Contributor
    • May 2007
    • 664

    #2
    Originally posted by preeti13
    I have a datagrid with a hyperlink field. It passes a parameter but I need
    it to pass two. I need two of the parameters to be querystrings but I have no idea how to add them the hyperlink column if any one know about this then please help me .
    here is my code:

    [HTML]
    <asp:datagrid id="DataGrid1" runat="server" AutoGenerateCol umns="False" AlternatingItem Style-BorderStyle="Do tted" BorderColor="Bl ack" BorderStyle="So lid" Width="650px">
    <AlternatingIte mStyle BorderStyle="Do tted"></AlternatingItem Style>
    <Columns>
    <asp:BoundColum n DataField="Nomi natedByfirstnam e" HeaderText="Nom inated By First name">
    <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
    </asp:BoundColumn >
    <asp:BoundColum n DataField="Nomi natedByLastName " HeaderText="Nom inated By Last Name">
    <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
    </asp:BoundColumn >
    <asp:BoundColum n DataField="Nomi neefirstName" HeaderText="Nom inee First Name">
    <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
    </asp:BoundColumn >
    <asp:BoundColum n DataField="Nomi neeLastName" HeaderText="Nom inee Last Name">
    <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
    </asp:BoundColumn >
    <asp:BoundColum n DataField="Nomi neeDept" HeaderText="Nom inee Dept">
    <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
    </asp:BoundColumn >
    <asp:BoundColum n DataField="Date Created" HeaderText="Dat e Created">
    <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
    </asp:BoundColumn >
    <asp:HyperLinkC olumn Text="Detail" HeaderStyle-BackColor="#316 AC5" HeaderText="Det ail" HeaderStyle-ForeColor="Whit e" HeaderStyle-Font-Bold="True" DataNavigateUrl Field="employee nominationid" DataNavigateUrl FormatString="R easonfornominat ing.aspx?employ eenominationid= {0}"></asp:HyperLinkCo lumn>
    <Columns>
    </asp:datagrid>
    [/HTML]
    Try doing this. Create a new TemplateColumn and an ItemTemplate. Create a new hyperlink in your ItemTemplate.

    Originally posted by nsasek
    You will need to do the following:

    <asp:TemplateCo lumn HeaderText="Ord er">

    <ItemTemplate >

    <asp:Hyperlin k runat="server"
    Text='<%#DataBi nder.Eval(Conta iner.DataItem," OrderID")%>' NavigateUrl='<% #
    "Reasonfornomin ating.aspx?empl oyeenominationi d=" + DataBinder.Eval (Container.Data Item,"employeen ominationid") +
    "&String2=" + DataBinder.Eval (Container.Data Item,"String2") %>'
    ID="Hyperlink1 " NAME="Hyperlink 1"/>

    </ItemTemplate>

    </asp:TemplateCol umn>

    employeenominat ionid and String2 should both be in the dataset used as the datasource of your datagrid. Give this a try and let us know if you encounter any more problems.

    Nathan

    Comment

    • preeti13
      New Member
      • Aug 2007
      • 67

      #3
      now i got this error

      Compilation Error
      Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

      Compiler Error Message: CS1010: Newline in constant

      Source Error:



      Line 112: #line default
      Line 113: #line hidden
      Line 114:
      Line 115:
      Line 116: #line 46 "http://localhost/Employee Nomination/NominationRepor t.aspx"

      code is look like this:

      [HTML]
      <asp:datagrid id="DataGrid1" runat="server" AutoGenerateCol umns="False" AlternatingItem Style-BorderStyle="Do tted"
      BorderColor="Bl ack" BorderStyle="So lid" Width="650px">
      <AlternatingIte mStyle BorderStyle="Do tted"></AlternatingItem Style>
      <Columns>
      <asp:BoundColum n DataField="Nomi natedByfirstnam e" HeaderText="Nom inated By First name">
      <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
      </asp:BoundColumn >
      <asp:BoundColum n DataField="Nomi natedByLastName " HeaderText="Nom inated By Last Name">
      <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
      </asp:BoundColumn >
      <asp:BoundColum n DataField="Nomi neefirstName" HeaderText="Nom inee First Name">
      <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
      </asp:BoundColumn >
      <asp:BoundColum n DataField="Nomi neeLastName" HeaderText="Nom inee Last Name">
      <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
      </asp:BoundColumn >
      <asp:BoundColum n DataField="Nomi neeDept" HeaderText="Nom inee Dept">
      <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
      </asp:BoundColumn >
      <asp:BoundColum n DataField="Date Created" HeaderText="Dat e Created">
      <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
      </asp:BoundColumn >
      <asp:TemplateCo lumn HeaderText=Deta il>
      <ItemTemplate >
      <asp:HyperLin k Runat=server NavigateUrl=<%# "Reasonfornomin ating.aspx?empl oyeenominationi d=" +
      DataBinder.Eval (Container.Data Item,"employeen ominationid") +<BR>"&datecrea ted="+ DataBinder.Eval (Container.Data Item,"datecreat ed%> ID="Hyperlink1" ></asp:HyperLink>
      </ItemTemplate>
      </asp:TemplateCol umn>
      </Columns>
      </asp:datagrid>
      [/HTML]
      [PHP]
      and one more thing i neeg to teel you i didn't found the property call NAME AND TEXT
      [/PHP]

      Comment

      • nateraaaa
        Recognized Expert Contributor
        • May 2007
        • 664

        #4
        Originally posted by preeti13
        now i got this error

        Compilation Error
        Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

        Compiler Error Message: CS1010: Newline in constant

        Source Error:



        Line 112: #line default
        Line 113: #line hidden
        Line 114:
        Line 115:
        Line 116: #line 46 "http://localhost/Employee Nomination/NominationRepor t.aspx"

        code is look like this:

        [HTML]
        <asp:datagrid id="DataGrid1" runat="server" AutoGenerateCol umns="False" AlternatingItem Style-BorderStyle="Do tted"
        BorderColor="Bl ack" BorderStyle="So lid" Width="650px">
        <AlternatingIte mStyle BorderStyle="Do tted"></AlternatingItem Style>
        <Columns>
        <asp:BoundColum n DataField="Nomi natedByfirstnam e" HeaderText="Nom inated By First name">
        <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
        </asp:BoundColumn >
        <asp:BoundColum n DataField="Nomi natedByLastName " HeaderText="Nom inated By Last Name">
        <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
        </asp:BoundColumn >
        <asp:BoundColum n DataField="Nomi neefirstName" HeaderText="Nom inee First Name">
        <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
        </asp:BoundColumn >
        <asp:BoundColum n DataField="Nomi neeLastName" HeaderText="Nom inee Last Name">
        <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
        </asp:BoundColumn >
        <asp:BoundColum n DataField="Nomi neeDept" HeaderText="Nom inee Dept">
        <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
        </asp:BoundColumn >
        <asp:BoundColum n DataField="Date Created" HeaderText="Dat e Created">
        <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
        </asp:BoundColumn >
        <asp:TemplateCo lumn HeaderText=Deta il>
        <ItemTemplate >
        <asp:HyperLin k Runat=server NavigateUrl=<%# "Reasonfornomin ating.aspx?empl oyeenominationi d=" +
        DataBinder.Eval (Container.Data Item,"employeen ominationid") +<BR>"&datecrea ted="+ DataBinder.Eval (Container.Data Item,"datecreat ed%> ID="Hyperlink1" ></asp:HyperLink>
        </ItemTemplate>
        </asp:TemplateCol umn>
        </Columns>
        </asp:datagrid>
        [/HTML]
        [PHP]
        and one more thing i neeg to teel you i didn't found the property call NAME AND TEXT
        [/PHP]
        Here is what you need to do to fix this error.
        It appears that you did not close your Eval statement

        [HTML]DataBinder.Eval (Container.Data Item,"datecreat ed%> [/HTML]
        replace with this
        [HTML]DataBinder.Eval (Container.Data Item,"datecreat ed")%> [/HTML]
        Also not sure why there is a <BR> in your code (that may have been added inadvertently but make sure that is not in your code).
        You can assign the text value of the hyperlink in the codebehind file.
        Code:
        HyperLink1.Text = "Whatever you want";
        Nathan

        Comment

        • nateraaaa
          Recognized Expert Contributor
          • May 2007
          • 664

          #5
          It appears that you did not close your Eval statement

          [HTML]DataBinder.Eval (Container.Data Item,"datecreat ed%> [/HTML]
          replace with this
          [HTML]DataBinder.Eval (Container.Data Item,"datecreat ed")%> [/HTML]
          Also not sure why there is a <BR> in your code (that may have been added inadvertently but make sure that is not in your code).
          You can assign the text value of the hyperlink in the codebehind file.
          Code:
          HyperLink1.Text = "Whatever you want";
          Nathan

          Comment

          • preeti13
            New Member
            • Aug 2007
            • 67

            #6
            where is the answer i didn't find it

            Originally posted by nateraaaa
            Here is what you need to do to fix this error.
            It appears that you did not close your Eval statement

            [HTML]DataBinder.Eval (Container.Data Item,"datecreat ed%> [/HTML]
            replace with this
            [HTML]DataBinder.Eval (Container.Data Item,"datecreat ed")%> [/HTML]
            Also not sure why there is a <BR> in your code (that may have been added inadvertently but make sure that is not in your code).
            You can assign the text value of the hyperlink in the codebehind file.
            Code:
            HyperLink1.Text = "Whatever you want";
            Nathan

            Comment

            • preeti13
              New Member
              • Aug 2007
              • 67

              #7
              hey i am still getting the same error please help me
              code is here
              [HTML]

              <asp:datagrid id="DataGrid1" runat="server" AutoGenerateCol umns="False" AlternatingItem Style-BorderStyle="Do tted"
              BorderColor="Bl ack" BorderStyle="So lid" Width="650px">
              <AlternatingIte mStyle BorderStyle="Do tted"></AlternatingItem Style>
              <Columns>
              <asp:BoundColum n DataField="Nomi natedByfirstnam e" HeaderText="Nom inated By First name">
              <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
              </asp:BoundColumn >
              <asp:BoundColum n DataField="Nomi natedByLastName " HeaderText="Nom inated By Last Name">
              <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
              </asp:BoundColumn >
              <asp:BoundColum n DataField="Nomi neefirstName" HeaderText="Nom inee First Name">
              <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
              </asp:BoundColumn >
              <asp:BoundColum n DataField="Nomi neeLastName" HeaderText="Nom inee Last Name">
              <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
              </asp:BoundColumn >
              <asp:BoundColum n DataField="Nomi neeDept" HeaderText="Nom inee Dept">
              <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
              </asp:BoundColumn >
              <asp:BoundColum n DataField="Date Created" HeaderText="Dat e Created">
              <HeaderStyle Font-Size="10pt" Font-Bold="True" ForeColor="Whit e" BackColor="#316 AC5"></HeaderStyle>
              </asp:BoundColumn >
              <asp:TemplateCo lumn HeaderText=Deta il>
              <ItemTemplate >
              <asp:HyperLin k Runat=server NavigateUrl=<%# "Reasonfornomin ating.aspx?empl oyeenominationi d="+DataBinder. Eval(Container. DataItem,"emplo yeenominationid ")+"&datecreate d="+ DataBinder.Eval (Container.Data Item,"datecreat ed%> ID="Hyperlink1" ></asp:HyperLink>
              </ItemTemplate>
              </asp:TemplateCol umn>
              </Columns>
              </asp:datagrid>
              [/HTML]

              Comment

              • nateraaaa
                Recognized Expert Contributor
                • May 2007
                • 664

                #8
                Replace this code

                <asp:HyperLin k Runat=server NavigateUrl=<%# "Reasonfornomin ating.aspx?empl oyeenominationi d="+DataBinder. Eval(Container. DataItem,"emplo yeenominationid ")+"&datecreate d="+ DataBinder.Eval (Container.Data Item,"datecreat ed%> //missing the ") to close the Eval statement on this line.
                ID="Hyperlink1" ></asp:HyperLink>

                with this code

                <asp:HyperLin k Runat=server NavigateUrl=<%# "Reasonfornomin ating.aspx?empl oyeenominationi d="+DataBinder. Eval(Container. DataItem,"emplo yeenominationid ")+"&datecreate d="+ DataBinder.Eval (Container.Data Item,"datecreat ed")%> ID="Hyperlink1" ></asp:HyperLink>

                Comment

                • preeti13
                  New Member
                  • Aug 2007
                  • 67

                  #9
                  tanks very much for helping me thanks a lot my probelm is solved

                  Comment

                  Working...