mardi 4 août 2015

How can I navigate to a different URL when user clicks the hyperlink in the GridView with a condition?

I am a beginner in learning asp.net. I have a column in a GridView with header name FORM ID. I want to be able to navigate to the different URL based on the part of the FORM ID.

For example,

  • Clicking on abc10001 will take us to "~/abc1.aspx?formid=abc10001"
  • Clicking on abc20001 will take us to "~/abc2.aspx?formid=abc20001"

I understand the use of the MID function like so v=MID(string,4,1) to capture the 4th value and redirect to page by determining the value v but I do not know how to apply this correctly. Please guide me. Your help is greatly appreciated.

The following is the aspx code I'm currently work on :

<asp:GridView ID="gridview1" runat="server" AutoGenerateColumns="false">           
    <columns>
        <asp:Hyperlinkfield DataTextField="formid" HeaderText="Form ID" ItemStyle-  Width="150px" 
            DataNavigateUrlFields="formid" DataNavigateUrlFormatString="~/abc1.aspx" />         
    </Columns>
</asp:GridView>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire