Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to merge two column in gridview

I have a gridview

        <asp:BoundField DataField="UnusedTicketAmount" HeaderText="UnusedTicketAmount" />
        <asp:BoundField DataField="ddlUnusedAmount" HeaderText="ddlUnusedAmount" />
        <asp:BoundField DataField="AirlinePenality" HeaderText="AirlinePenality" />
        <asp:BoundField DataField="ddlAirlinePenality" HeaderText="ddlAirlinePenality" />
        <asp:BoundField DataField="NetRefundProcess" HeaderText="NetRefundProcess" />
        <asp:BoundField DataField="ddlNetRefundProcess" HeaderText="ddlNetRefundProcess" />
        <asp:BoundField DataField="RefundableCommission" HeaderText="RefundableCommission" />
        <asp:BoundField DataField="ddlRefundableCommission" HeaderText="ddlRefundableCommission" />
        <asp:BoundField DataField="CouponRefunded" HeaderText="CouponRefunded" />
        <asp:BoundField DataField="RefundType" HeaderText="RefundType" /> 

in this gridview i want to add airlinepenality and ddlairlinepanelity to one column how can i do that thanks in advance

like image 366
amitesh Avatar asked Apr 02 '13 14:04

amitesh


2 Answers

You can create a template field and bind two fields like this.

<asp:TemplateField HeaderText="Airlinepenality"   SortExpression="ddlAirlinePenality">
<ItemTemplate>
    <asp:Label ID="Label1" runat="server" Text='<%#Eval("AirlinePenality")+ " " + Eval("ddlAirlinePenality")%>' ></asp:Label>
</ItemTemplate>

like image 82
Anıl Canlı Avatar answered Oct 14 '22 14:10

Anıl Canlı


you are using Bound field, we can merge two columns by TemplateField only, So better you can merge that two columns in your query,

try like below...

Query:

SELECT UnusedTicketAmount, ddlUnusedAmount, 
cast(1.25 as varchar) + ' ' + cast(172813.99 as varchar) as AirlinePenality,
NetRefundProcess,ddlNetRefundProcess,RefundableCommission
ddlRefundableCommission,CouponRefunded,RefundType

Gridview

<asp:BoundField DataField="UnusedTicketAmount" HeaderText="UnusedTicketAmount" />
<asp:BoundField DataField="ddlUnusedAmount" HeaderText="ddlUnusedAmount" />
<asp:BoundField DataField="AirlinePenality" HeaderText="AirlinePenality" />
<asp:BoundField DataField="NetRefundProcess" HeaderText="NetRefundProcess" />
<asp:BoundField DataField="ddlNetRefundProcess" HeaderText="ddlNetRefundProcess" />
<asp:BoundField DataField="RefundableCommission" HeaderText="RefundableCommission" />
<asp:BoundField DataField="ddlRefundableCommission" HeaderText="ddlRefundableCommission" />
<asp:BoundField DataField="CouponRefunded" HeaderText="CouponRefunded" />
<asp:BoundField DataField="RefundType" HeaderText="RefundType" /> 
like image 30
Pandian Avatar answered Oct 14 '22 14:10

Pandian