Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Putting a link in a WebDataGrid


I am trying to put a link button on a WebDataGrid and i am having some trouble and there doesnt appear to be much reference material about it. I have a search feature for a website i am developing and this search feature will return any records that match the search input. I am trying to put a link that allows the user to select a search result and view it in more detail. I have the gird set up and populating correctly, i just can seem to figure out how to reference a particular cell's value to use as part of the query is what i have:


        <ig:TemplateDataField Key="URL"><ItemTemplate><asp:LinkButton ID="LinkButton1" runat ="server" Text="View"  OnClick = "btnGetWorkOrder_Click" /></ItemTemplate></ig:TemplateDataField>
            <ig:BoundDataField DataFieldName="tie_in_record_num" Key="tie_in_record_num" >
                <Header Text="Record No." />
            <ig:BoundDataField DataFieldName="date_added" Key="date_added">
                <Header Text="Date" />
            <ig:BoundDataField DataFieldName="WO_num" Key="WO_num">
                <Header Text="WO Num" />
            <ig:BoundDataField DataFieldName="tie_in_subject" Key="tie_in_subject">
                <Header Text="Subject" />
            <ig:BoundDataField DataFieldName="fullname" Key="fullname">
                <Header Text="Fullname" />
            <ig:BoundDataField DataFieldName="equip_location" Key="equip_location">
                <Header Text="Location" />
            <ig:Paging PagerAppearance="Bottom" PageSize="10" />
            <ig:Sorting SortingMode="Single" Enabled="true">
                <ig:SortingColumnSetting ColumnKey="tie_in_record_num" />
                <ig:SortingColumnSetting ColumnKey="date_added" />
                <ig:SortingColumnSetting ColumnKey="tie_in_subject" />
                <ig:SortingColumnSetting ColumnKey="WO_num" />
                <ig:SortingColumnSetting ColumnKey="equip_location" />
                <ig:SortingColumnSetting ColumnKey="fullname" />
    <ErrorTemplate>Error with the search, please contact IT</ErrorTemplate>
    <div style="text-align: center"><span style="color: red; font-size: x-large"><strong>
     <br />No Tie-Ins Found<br /> <br /></strong></span></div>



    protected void btnGetWorkOrder_Click(object sender, EventArgs e)
        Response.Redirect("view.aspx?WO_num=" + Request.Url.Query);


So when the "View" button is clicked, i need it to reference the  WO_num cell in the row and use that value as the "Request.Url.Query" value. Right now i know that the Request.Url.Query isnt the right statement to go there but i am still not sure how to reference that cell...any thoughts?

  • 49378

    Hi is510d,

    As far as I can understand you are looking for a way to access the row index (and from there the cell index) of the row whose templated button was clicked. This can be done using code similar to:

        protected void TemplateButton1_Click(object sender, EventArgs e)
            var a = ((DataRecord) ((Infragistics.Web.UI.TemplateContainer) (((Button) sender).Parent)).DataItem).DataSourceIndex;

    You can find additional detailed information on working with templated controls in the following discussion:

    Please contact me if you have any questions.

    Best Regards,

    Petar Ivanov
    Developer Support Engineer
    Infragistics, Inc.