Hi,

I have to make a datagridview and join three tables which have realtionships in my database and i need to display some of the data in these tables in a datagridview can u toutor me pls?

Recommended Answers

All 3 Replies

You, can add what ever columns you want to the database by setting the Datagrid.Datasource()= Dataset.Tables(0); and also refer the following Coding.

<table id="tblPlay" style="z-index: 101; position: absolute; top: 137px; left: 1%"
        cellspacing="0" cellpadding="0" border="0">
        <tr>
            <td style="height: 22px">
                <asp:DataGrid ID="CMSgrid" runat="server" Width="100%" CellPadding="1" BackColor="LightGoldenrodYellow"
                    BorderWidth="0px" BorderStyle="None" BorderColor="Gold" AutoGenerateColumns="False"
                    AllowPaging="True" Font-Size="10px" ForeColor="Black" CellSpacing="1" Font-Names="Verdana"
                    PageSize="10" OnItemDataBound="CMSgrid_ItemDataBound" HorizontalAlign="Left"
                    Height="74px" ToolTip="Editing Complaint Status" ItemStyle-VerticalAlign="Top" AllowSorting="true" >
                    <FooterStyle BackColor="Tan"></FooterStyle>
                    <SelectedItemStyle Font-Size="10px" Font-Names="Verdana" HorizontalAlign="Left" ForeColor="Black"
                        VerticalAlign="Middle" BackColor="Gold"></SelectedItemStyle>
                    <EditItemStyle Font-Size="10px" Font-Names="Verdana" HorizontalAlign="Left" ForeColor="Black"
                        VerticalAlign="Middle" BackColor="Gold"></EditItemStyle>
                    <AlternatingItemStyle HorizontalAlign="Left" VerticalAlign="Middle" BackColor="PaleGoldenrod">
                    </AlternatingItemStyle>
                    <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle"></ItemStyle>
                    <HeaderStyle Font-Size="10px" Font-Names="Verdana" Font-Bold="True" CssClass="DataGridFixedHeader"
                        BackColor="Tan"></HeaderStyle>
                    <Columns>
                        <asp:TemplateColumn Visible="False">
                            <HeaderStyle Width="50px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:CheckBox ID="ckSelect" runat="server" Font-Size="1px" Width="1px" Height="1px"
                                    AutoPostBack="True" Font-Names="Verdana"></asp:CheckBox>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn>
                            <HeaderStyle Width="40px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:ImageButton ID="btnedit" ToolTip="Edit" runat="server" ImageUrl="./images/EDIT.ICO"
                                    CommandName="Edit" CausesValidation="false"></asp:ImageButton>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:ImageButton ID="btnsave" ToolTip="Save" runat="server" ImageUrl="./images/insert.jpg"
                                    CommandName="Update"></asp:ImageButton>&nbsp;
                                <asp:ImageButton ID="btncancel" ToolTip="Cancel" runat="server" ImageUrl="./images/Delete.png"
                                    CommandName="Cancel" CausesValidation="false"></asp:ImageButton>
                            </EditItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn>
                            <HeaderStyle Width="20px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:LinkButton ID="btnDelete" runat="server" ToolTip="Delete" Text="<img border=0 src=./images/delete.png>"
                                    CommandName="Delete" CausesValidation="false"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn SortExpression="complaintnumber" HeaderText="Complaint No.">
                            <HeaderStyle Width="80px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblFilename" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ComplaintNumber") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn HeaderText="Employee No." SortExpression="EmployeeNo">
                            <HeaderStyle Width="120px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblEmpNo" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.EmployeeNo") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn HeaderText="Contact No." SortExpression="FaultyDeviceNo">
                            <HeaderStyle Width="95px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblDeviceNo" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.FaultyDeviceNo") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn HeaderText="Category" SortExpression="CategoryName">
                            <HeaderStyle Width="280px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="Category" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.CategoryName") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <%-- <asp:TemplateColumn HeaderText="Description">
                            <HeaderStyle Width="75px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblDescription" Text='<%# DataBinder.Eval(Container, "DataItem.Description") %>'
                                    runat="server">
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>--%>
                        <%-- <asp:TemplateColumn HeaderText="Location">
                            <HeaderStyle Width="75px"></HeaderStyle>
                            <ItemStyle Wrap="False"></ItemStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblLocation" Text='<%# DataBinder.Eval(Container, "DataItem.LocationName") %>'
                                    runat="server">
                                </asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="ddlLocation" Font-Names="Verdana" Font-Size="8pt" Width="120px"
                                    runat="server" DataTextField="LocationName" DataSource="<%# LocationDisp() %>">
                                </asp:DropDownList>
                            </EditItemTemplate>
                        </asp:TemplateColumn>--%>
                        <%--<asp:TemplateColumn HeaderText="Contact Number">
                            <HeaderStyle Width="100px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblcontNumber" Text='<%# DataBinder.Eval(Container, "DataItem.contactnumber") %>'
                                    runat="server">
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>--%>
                        <asp:TemplateColumn HeaderText="Registered Date and Time" SortExpression="StartDate">
                            <HeaderStyle Width="360px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="StartDate" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.StartDate", "{0:d-MMM-yy hh:mm tt}") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn HeaderText="Service Person" Visible="false">
                            <HeaderStyle Width="100px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblServicePerson" Text='<%# DataBinder.Eval(Container, "DataItem.ServicePerson") %>'
                                    runat="server">
                                </asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="ddlServicePerson" Font-Names="Verdana" Font-Size="8pt" Width="112px"
                                    runat="server" DataTextField="PersonName" DataSource="<%# ServicePersonDisp() %>">
                                </asp:DropDownList>
                            </EditItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn HeaderText="Status" SortExpression="Statusname">
                            <HeaderStyle Width="80px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblStatus" Text='<%# Eval("Statusname") %>' runat="server">
                                </asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="ddlStatus" Font-Names="Verdana" Font-Size="8pt" Width="104px"
                                    runat="server" DataTextField="statusname" OnSelectedIndexChanged="ddlStatus_ShowCalender"
                                    AutoPostBack="True" DataSource="<%# itemcollections() %>">
                                </asp:DropDownList>
                            </EditItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn HeaderText="Completed Date and Time" SortExpression="EndDate">
                            <HeaderStyle Width="360px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblEndDate" runat="server" Text='<%#Eval("EndDate", "{0:d-MMM-yy hh:mm tt}") %>'>
                                </asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:Label ID="lblHiddenEndDate" runat="server" Width="200px" Text='<%# DataBinder.Eval(Container, "DataItem.EndDate", "{0:d-MMM-yy h:mm:ss tt}") %>'>
                                </asp:Label>
                                <button runat="server" visible="false" style="width: 24px; height: 12px" id="btnEndDate"
                                    title="Click to edit the completed date" onclick="launchCenter('Calendar.aspx','Calendar',260,110);"
                                    type="submit" value="...">
                                    .....</button>
                            </EditItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn HeaderText="Voice File Name" SortExpression="VoiceFileName">
                            <ItemTemplate>
                                <asp:Label ID="VoiceFileName" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.VoiceFileName") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn Visible="False" HeaderText="Duration">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="duration" Text='<%# DataBinder.Eval(Container, "DataItem.Duration") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn Visible="False" HeaderText="Caller Name">
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.CallerName") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn Visible="False" HeaderText="StatusID">
                            <ItemTemplate>
                                <asp:Label ID="sID" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.StatusID") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn Visible="False" HeaderText="YOC">
                            <ItemTemplate>
                                <asp:Label ID="lblYOC" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.YearOfComplaint") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn Visible="False" HeaderText="Select">
                            <ItemTemplate>
                                <asp:LinkButton ID="LB" runat="server" Text="Select" CommandName="Select"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <%--<asp:TemplateColumn  HeaderText="Category">
                            <ItemTemplate>
                                <asp:Label ID="lblCategoryID" runat = "server" Text='<%#DataBinder.Eval(Container,"DataItem.Value")%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>--%>
                        <asp:TemplateColumn HeaderText="SubCategory" SortExpression="Cvalue1">
                            <HeaderStyle Width="350px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblCategory1" runat="server" Text='<%#DataBinder.Eval(Container,"DataItem.Cvalue1")%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <%-- <asp:TemplateColumn  HeaderText="SubCategory2">
                        <HeaderStyle Width="280px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblCategory2" runat = "server" Text='<%#DataBinder.Eval(Container,"DataItem.Cvalue2")%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn  HeaderText="SubCategory3">
                        <HeaderStyle Width="400px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblCategory3" runat = "server" Text='<%#DataBinder.Eval(Container,"DataItem.Cvalue3")%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>--%>
                        <asp:TemplateColumn HeaderText="Remarks" SortExpression="Remarks">
                            <HeaderStyle Width="180px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblRemarks" runat="server" Text='<%#DataBinder.Eval(Container,"DataItem.Remarks")%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                    </Columns>
                    <PagerStyle NextPageText="Next" Font-Names="Verdana" Font-Bold="True" PrevPageText="Prev"
                        HorizontalAlign="Left" ForeColor="Black" BackColor="Tan"></PagerStyle>
                </asp:DataGrid>
            </td>
        </tr>
        <tr>
            <td style="height: 3px">
                <asp:TextBox ID="txtFilename" runat="server" Width="8px" Height="8px" Visible="False"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="height: 7px">
                <input onmousedown="this.style.color = 'gold';" id="btnDeleteAll" onmouseover="this.style.color = 'white';"
                    style="background-image: url(./images/Button.gif); border-bottom-style: none;
                    border-right-style: none; background-color: transparent; width: 96px; font-family: Verdana;
                    border-top-style: none; height: 32px; color: gold; font-size: 13px; border-left-style: none;
                    cursor: hand; font-weight: normal" onclick="if(confirm('Are you sure you want to delete all the records?')){return true}else {return false;}"
                    onmouseout="this.style.color = 'gold';" type="submit" value="Delete All" name="btn_DeleteAll"
                    runat="server" visible="false" /><input onmousedown="this.style.color = 'gold';"
                    id="btnReport" onmouseover="this.style.color = 'white';" style="background-image: url(./images/Button.gif);
                    border-bottom-style: none; border-right-style: none; background-color: transparent;
                    width: 96px; font-family: Verdana; border-top-style: none; height: 32px; color: gold;
                    font-size: 13px; border-left-style: none; cursor: hand; font-weight: normal"
                    onmouseout="this.style.color = 'gold';" type="button" value="Report" name="Button2"
                    runat="server" /><input onmousedown="this.style.color = 'gold';" id="btnTicket" onmouseover="this.style.color = 'white';"
                    style="background-image: url(./images/Button.gif); border-bottom-style: none;
                    border-right-style: none; background-color: transparent; width: 96px; font-family: Verdana;
                    border-top-style: none; height: 32px; color: gold; font-size: 13px; border-left-style: none;
                    cursor: hand; font-weight: normal" onmouseout="this.style.color = 'gold';" type="button"
                    value="Ticket" name="Button3" runat="server" /><input onmousedown="this.style.color = 'gold';"
                    id="btnDownload" visible="false" onmouseover="this.style.color = 'white';" style="background-image: url(./images/Button.gif);
                    border-bottom-style: none; border-right-style: none; background-color: transparent;
                    width: 96px; font-family: Verdana; border-top-style: none; height: 32px; color: gold;
                    font-size: 13px; border-left-style: none; cursor: hand; font-weight: normal"
                    onmouseout="this.style.color = 'gold';" type="button" value="Download" name="Button4"
                    runat="server" /><input onmousedown="this.style.color = 'gold';" id="btnPlay" onmouseover="this.style.color = 'white';"
                    style="background-image: url(./images/BigButton.gif); border-bottom-style: none;
                    border-right-style: none; background-color: transparent; width: 120px; font-family: Verdana;
                    border-top-style: none; height: 32px; color: gold; font-size: 11px; border-left-style: none;
                    cursor: hand; font-weight: normal" onmouseout="this.style.color = 'gold';" type="submit"
                    value="Play Complaint" name="Button5" runat="server" /><input onmousedown="this.style.color = 'gold';"
                    id="btnAddNewComplaint" onmouseover="this.style.color = 'white';" style="background-image: url(./images/BigButton.gif);
                    border-bottom-style: none; border-right-style: none; background-color: transparent;
                    width: 120px; font-family: Verdana; border-top-style: none; height: 32px; color: gold;
                    font-size: 11px; border-left-style: none; cursor: hand; font-weight: normal"
                    onmouseout="this.style.color = 'gold';" type="submit" value="New Complaint" name="Add user"
                    runat="server" /><input onmousedown="this.style.color = 'gold';" id="btnSearch" onmouseover="this.style.color = 'white';"
                    style="background-image: url(./images/Button.gif); border-bottom-style: none;
                    border-right-style: none; background-color: transparent; width: 96px; font-family: Verdana;
                    border-top-style: none; height: 32px; color: gold; font-size: 13px; border-left-style: none;
                    cursor: hand; font-weight: normal" onmouseout="this.style.color = 'gold';" type="button"
                    value="Search" name="Button1" runat="server" />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               <asp:Button ID="btnDeleteRecording" runat="server" Width="8px" BackColor="Transparent"
                    BorderStyle="None" Text="   i." Enabled="False"></asp:Button><asp:Button ID="btnToPlay"
                    runat="server" Width="8px" BackColor="Transparent" BorderStyle="None" Text="      l">
                    </asp:Button><asp:Label ID="lblCNT" runat="server" Width="8px" Font-Size="8px" Height="4px"
                    Visible="False">0</asp:Label><asp:TextBox ID="txtScroll" runat="server" Width="8px"
                    BackColor="Transparent" BorderStyle="None" Font-Size="1pt" ForeColor="Silver">0</asp:TextBox><asp:TextBox
                    ID="txtUsername" runat="server" Width="16px" Visible="False"></asp:TextBox><asp:TextBox
                    ID="txtUserType" runat="server" Width="16px" Visible="False"></asp:TextBox><asp:TextBox
                    ID="txtPageIndex" runat="server" Width="16px" Height="7px" Visible="False">-1</asp:TextBox><asp:TextBox
                    ID="txtEditIndex" runat="server" Width="16px" Height="7px" Visible="False">-1</asp:TextBox>
            </td>
        </tr>
        <td width="45%" align="left" style="visibility: hidden">
            <table id='tblRecordPlay' cellpadding="0" cellspacing="0" style='position: absolute;
                top: 90%; left: 1000px; border: 1px solid white; z-index: 105;'>
                <tr>
                    <td>
                        <object id='MediaPlayer' width='300' height='45' classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95'
                            standby='Loading Windows Media Player components...' type='application/x-oleobject'>
                            " & _ "<param id='fname' runat="server" name='FileName' value='' />" & _ "<param
                                name='autostart' value='false' />" & _ "<param name='ShowControls' value='true' />"
                            & _ "<param name='ShowStatusBar' value='false' />" & _ "<param name='ShowDisplay'
                                value='false' />" & _ "</object>
                    </td>
                </tr>
            </table>
        </td>
    </table>

I have found a better vway to do it without haveing to do a code thx anyway :)

You, can add what ever columns you want to the database by setting the Datagrid.Datasource()= Dataset.Tables(0); and also refer the following Coding.

<table id="tblPlay" style="z-index: 101; position: absolute; top: 137px; left: 1%"
        cellspacing="0" cellpadding="0" border="0">
        <tr>
            <td style="height: 22px">
                <asp:DataGrid ID="CMSgrid" runat="server" Width="100%" CellPadding="1" BackColor="LightGoldenrodYellow"
                    BorderWidth="0px" BorderStyle="None" BorderColor="Gold" AutoGenerateColumns="False"
                    AllowPaging="True" Font-Size="10px" ForeColor="Black" CellSpacing="1" Font-Names="Verdana"
                    PageSize="10" OnItemDataBound="CMSgrid_ItemDataBound" HorizontalAlign="Left"
                    Height="74px" ToolTip="Editing Complaint Status" ItemStyle-VerticalAlign="Top" AllowSorting="true" >
                    <FooterStyle BackColor="Tan"></FooterStyle>
                    <SelectedItemStyle Font-Size="10px" Font-Names="Verdana" HorizontalAlign="Left" ForeColor="Black"
                        VerticalAlign="Middle" BackColor="Gold"></SelectedItemStyle>
                    <EditItemStyle Font-Size="10px" Font-Names="Verdana" HorizontalAlign="Left" ForeColor="Black"
                        VerticalAlign="Middle" BackColor="Gold"></EditItemStyle>
                    <AlternatingItemStyle HorizontalAlign="Left" VerticalAlign="Middle" BackColor="PaleGoldenrod">
                    </AlternatingItemStyle>
                    <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle"></ItemStyle>
                    <HeaderStyle Font-Size="10px" Font-Names="Verdana" Font-Bold="True" CssClass="DataGridFixedHeader"
                        BackColor="Tan"></HeaderStyle>
                    <Columns>
                        <asp:TemplateColumn Visible="False">
                            <HeaderStyle Width="50px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:CheckBox ID="ckSelect" runat="server" Font-Size="1px" Width="1px" Height="1px"
                                    AutoPostBack="True" Font-Names="Verdana"></asp:CheckBox>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn>
                            <HeaderStyle Width="40px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:ImageButton ID="btnedit" ToolTip="Edit" runat="server" ImageUrl="./images/EDIT.ICO"
                                    CommandName="Edit" CausesValidation="false"></asp:ImageButton>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:ImageButton ID="btnsave" ToolTip="Save" runat="server" ImageUrl="./images/insert.jpg"
                                    CommandName="Update"></asp:ImageButton>&nbsp;
                                <asp:ImageButton ID="btncancel" ToolTip="Cancel" runat="server" ImageUrl="./images/Delete.png"
                                    CommandName="Cancel" CausesValidation="false"></asp:ImageButton>
                            </EditItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn>
                            <HeaderStyle Width="20px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:LinkButton ID="btnDelete" runat="server" ToolTip="Delete" Text="<img border=0 src=./images/delete.png>"
                                    CommandName="Delete" CausesValidation="false"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn SortExpression="complaintnumber" HeaderText="Complaint No.">
                            <HeaderStyle Width="80px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblFilename" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ComplaintNumber") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn HeaderText="Employee No." SortExpression="EmployeeNo">
                            <HeaderStyle Width="120px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblEmpNo" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.EmployeeNo") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn HeaderText="Contact No." SortExpression="FaultyDeviceNo">
                            <HeaderStyle Width="95px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblDeviceNo" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.FaultyDeviceNo") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn HeaderText="Category" SortExpression="CategoryName">
                            <HeaderStyle Width="280px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="Category" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.CategoryName") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <%-- <asp:TemplateColumn HeaderText="Description">
                            <HeaderStyle Width="75px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblDescription" Text='<%# DataBinder.Eval(Container, "DataItem.Description") %>'
                                    runat="server">
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>--%>
                        <%-- <asp:TemplateColumn HeaderText="Location">
                            <HeaderStyle Width="75px"></HeaderStyle>
                            <ItemStyle Wrap="False"></ItemStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblLocation" Text='<%# DataBinder.Eval(Container, "DataItem.LocationName") %>'
                                    runat="server">
                                </asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="ddlLocation" Font-Names="Verdana" Font-Size="8pt" Width="120px"
                                    runat="server" DataTextField="LocationName" DataSource="<%# LocationDisp() %>">
                                </asp:DropDownList>
                            </EditItemTemplate>
                        </asp:TemplateColumn>--%>
                        <%--<asp:TemplateColumn HeaderText="Contact Number">
                            <HeaderStyle Width="100px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblcontNumber" Text='<%# DataBinder.Eval(Container, "DataItem.contactnumber") %>'
                                    runat="server">
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>--%>
                        <asp:TemplateColumn HeaderText="Registered Date and Time" SortExpression="StartDate">
                            <HeaderStyle Width="360px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="StartDate" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.StartDate", "{0:d-MMM-yy hh:mm tt}") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn HeaderText="Service Person" Visible="false">
                            <HeaderStyle Width="100px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblServicePerson" Text='<%# DataBinder.Eval(Container, "DataItem.ServicePerson") %>'
                                    runat="server">
                                </asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="ddlServicePerson" Font-Names="Verdana" Font-Size="8pt" Width="112px"
                                    runat="server" DataTextField="PersonName" DataSource="<%# ServicePersonDisp() %>">
                                </asp:DropDownList>
                            </EditItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn HeaderText="Status" SortExpression="Statusname">
                            <HeaderStyle Width="80px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblStatus" Text='<%# Eval("Statusname") %>' runat="server">
                                </asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="ddlStatus" Font-Names="Verdana" Font-Size="8pt" Width="104px"
                                    runat="server" DataTextField="statusname" OnSelectedIndexChanged="ddlStatus_ShowCalender"
                                    AutoPostBack="True" DataSource="<%# itemcollections() %>">
                                </asp:DropDownList>
                            </EditItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn HeaderText="Completed Date and Time" SortExpression="EndDate">
                            <HeaderStyle Width="360px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblEndDate" runat="server" Text='<%#Eval("EndDate", "{0:d-MMM-yy hh:mm tt}") %>'>
                                </asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:Label ID="lblHiddenEndDate" runat="server" Width="200px" Text='<%# DataBinder.Eval(Container, "DataItem.EndDate", "{0:d-MMM-yy h:mm:ss tt}") %>'>
                                </asp:Label>
                                <button runat="server" visible="false" style="width: 24px; height: 12px" id="btnEndDate"
                                    title="Click to edit the completed date" onclick="launchCenter('Calendar.aspx','Calendar',260,110);"
                                    type="submit" value="...">
                                    .....</button>
                            </EditItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn HeaderText="Voice File Name" SortExpression="VoiceFileName">
                            <ItemTemplate>
                                <asp:Label ID="VoiceFileName" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.VoiceFileName") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn Visible="False" HeaderText="Duration">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="duration" Text='<%# DataBinder.Eval(Container, "DataItem.Duration") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn Visible="False" HeaderText="Caller Name">
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.CallerName") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn Visible="False" HeaderText="StatusID">
                            <ItemTemplate>
                                <asp:Label ID="sID" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.StatusID") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn Visible="False" HeaderText="YOC">
                            <ItemTemplate>
                                <asp:Label ID="lblYOC" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.YearOfComplaint") %>'>
                                </asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn Visible="False" HeaderText="Select">
                            <ItemTemplate>
                                <asp:LinkButton ID="LB" runat="server" Text="Select" CommandName="Select"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <%--<asp:TemplateColumn  HeaderText="Category">
                            <ItemTemplate>
                                <asp:Label ID="lblCategoryID" runat = "server" Text='<%#DataBinder.Eval(Container,"DataItem.Value")%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>--%>
                        <asp:TemplateColumn HeaderText="SubCategory" SortExpression="Cvalue1">
                            <HeaderStyle Width="350px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblCategory1" runat="server" Text='<%#DataBinder.Eval(Container,"DataItem.Cvalue1")%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <%-- <asp:TemplateColumn  HeaderText="SubCategory2">
                        <HeaderStyle Width="280px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblCategory2" runat = "server" Text='<%#DataBinder.Eval(Container,"DataItem.Cvalue2")%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:TemplateColumn  HeaderText="SubCategory3">
                        <HeaderStyle Width="400px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblCategory3" runat = "server" Text='<%#DataBinder.Eval(Container,"DataItem.Cvalue3")%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>--%>
                        <asp:TemplateColumn HeaderText="Remarks" SortExpression="Remarks">
                            <HeaderStyle Width="180px"></HeaderStyle>
                            <ItemTemplate>
                                <asp:Label ID="lblRemarks" runat="server" Text='<%#DataBinder.Eval(Container,"DataItem.Remarks")%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                    </Columns>
                    <PagerStyle NextPageText="Next" Font-Names="Verdana" Font-Bold="True" PrevPageText="Prev"
                        HorizontalAlign="Left" ForeColor="Black" BackColor="Tan"></PagerStyle>
                </asp:DataGrid>
            </td>
        </tr>
        <tr>
            <td style="height: 3px">
                <asp:TextBox ID="txtFilename" runat="server" Width="8px" Height="8px" Visible="False"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="height: 7px">
                <input onmousedown="this.style.color = 'gold';" id="btnDeleteAll" onmouseover="this.style.color = 'white';"
                    style="background-image: url(./images/Button.gif); border-bottom-style: none;
                    border-right-style: none; background-color: transparent; width: 96px; font-family: Verdana;
                    border-top-style: none; height: 32px; color: gold; font-size: 13px; border-left-style: none;
                    cursor: hand; font-weight: normal" onclick="if(confirm('Are you sure you want to delete all the records?')){return true}else {return false;}"
                    onmouseout="this.style.color = 'gold';" type="submit" value="Delete All" name="btn_DeleteAll"
                    runat="server" visible="false" /><input onmousedown="this.style.color = 'gold';"
                    id="btnReport" onmouseover="this.style.color = 'white';" style="background-image: url(./images/Button.gif);
                    border-bottom-style: none; border-right-style: none; background-color: transparent;
                    width: 96px; font-family: Verdana; border-top-style: none; height: 32px; color: gold;
                    font-size: 13px; border-left-style: none; cursor: hand; font-weight: normal"
                    onmouseout="this.style.color = 'gold';" type="button" value="Report" name="Button2"
                    runat="server" /><input onmousedown="this.style.color = 'gold';" id="btnTicket" onmouseover="this.style.color = 'white';"
                    style="background-image: url(./images/Button.gif); border-bottom-style: none;
                    border-right-style: none; background-color: transparent; width: 96px; font-family: Verdana;
                    border-top-style: none; height: 32px; color: gold; font-size: 13px; border-left-style: none;
                    cursor: hand; font-weight: normal" onmouseout="this.style.color = 'gold';" type="button"
                    value="Ticket" name="Button3" runat="server" /><input onmousedown="this.style.color = 'gold';"
                    id="btnDownload" visible="false" onmouseover="this.style.color = 'white';" style="background-image: url(./images/Button.gif);
                    border-bottom-style: none; border-right-style: none; background-color: transparent;
                    width: 96px; font-family: Verdana; border-top-style: none; height: 32px; color: gold;
                    font-size: 13px; border-left-style: none; cursor: hand; font-weight: normal"
                    onmouseout="this.style.color = 'gold';" type="button" value="Download" name="Button4"
                    runat="server" /><input onmousedown="this.style.color = 'gold';" id="btnPlay" onmouseover="this.style.color = 'white';"
                    style="background-image: url(./images/BigButton.gif); border-bottom-style: none;
                    border-right-style: none; background-color: transparent; width: 120px; font-family: Verdana;
                    border-top-style: none; height: 32px; color: gold; font-size: 11px; border-left-style: none;
                    cursor: hand; font-weight: normal" onmouseout="this.style.color = 'gold';" type="submit"
                    value="Play Complaint" name="Button5" runat="server" /><input onmousedown="this.style.color = 'gold';"
                    id="btnAddNewComplaint" onmouseover="this.style.color = 'white';" style="background-image: url(./images/BigButton.gif);
                    border-bottom-style: none; border-right-style: none; background-color: transparent;
                    width: 120px; font-family: Verdana; border-top-style: none; height: 32px; color: gold;
                    font-size: 11px; border-left-style: none; cursor: hand; font-weight: normal"
                    onmouseout="this.style.color = 'gold';" type="submit" value="New Complaint" name="Add user"
                    runat="server" /><input onmousedown="this.style.color = 'gold';" id="btnSearch" onmouseover="this.style.color = 'white';"
                    style="background-image: url(./images/Button.gif); border-bottom-style: none;
                    border-right-style: none; background-color: transparent; width: 96px; font-family: Verdana;
                    border-top-style: none; height: 32px; color: gold; font-size: 13px; border-left-style: none;
                    cursor: hand; font-weight: normal" onmouseout="this.style.color = 'gold';" type="button"
                    value="Search" name="Button1" runat="server" />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               <asp:Button ID="btnDeleteRecording" runat="server" Width="8px" BackColor="Transparent"
                    BorderStyle="None" Text="   i." Enabled="False"></asp:Button><asp:Button ID="btnToPlay"
                    runat="server" Width="8px" BackColor="Transparent" BorderStyle="None" Text="      l">
                    </asp:Button><asp:Label ID="lblCNT" runat="server" Width="8px" Font-Size="8px" Height="4px"
                    Visible="False">0</asp:Label><asp:TextBox ID="txtScroll" runat="server" Width="8px"
                    BackColor="Transparent" BorderStyle="None" Font-Size="1pt" ForeColor="Silver">0</asp:TextBox><asp:TextBox
                    ID="txtUsername" runat="server" Width="16px" Visible="False"></asp:TextBox><asp:TextBox
                    ID="txtUserType" runat="server" Width="16px" Visible="False"></asp:TextBox><asp:TextBox
                    ID="txtPageIndex" runat="server" Width="16px" Height="7px" Visible="False">-1</asp:TextBox><asp:TextBox
                    ID="txtEditIndex" runat="server" Width="16px" Height="7px" Visible="False">-1</asp:TextBox>
            </td>
        </tr>
        <td width="45%" align="left" style="visibility: hidden">
            <table id='tblRecordPlay' cellpadding="0" cellspacing="0" style='position: absolute;
                top: 90%; left: 1000px; border: 1px solid white; z-index: 105;'>
                <tr>
                    <td>
                        <object id='MediaPlayer' width='300' height='45' classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95'
                            standby='Loading Windows Media Player components...' type='application/x-oleobject'>
                            " & _ "<param id='fname' runat="server" name='FileName' value='' />" & _ "<param
                                name='autostart' value='false' />" & _ "<param name='ShowControls' value='true' />"
                            & _ "<param name='ShowStatusBar' value='false' />" & _ "<param name='ShowDisplay'
                                value='false' />" & _ "</object>
                    </td>
                </tr>
            </table>
        </td>
    </table>

If you still havent found the best way of showing specific data in the dgv, would you let me know? And if there is any code you have, would be more then welcome.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.