레이블 컨트롤을 사용하여 GridView 마크 업에 열을 추가하여 결과를 다음과 같이 표시 할 수 있습니다.
마크 업이 필요합니다. 표시가 false로 설정됩니다.
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField Visible="false">
<ItemTemplate>
<asp:Label ID="label1" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
은 다음과 같이 당신의 결과를 라벨을 찾아 계산 RowDataBound 이벤트를 사용
void GridView1GridView_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
//find the control
var label1 = e.Item.FindControl("label1") as Label;
if (label1 != null)
{
if (!string.IsNullOrEmpty(tbInput1.Text) && !string.IsNullOrEmpty(tbInput2.Text))
{
// Do the calculation and set the label
label1.Text = tbInput1.Text + tbInput2.Text;
// Make the column visible
GridView1.Columns[0].Visible = true;
}
}
}
}
오류를 용서하십시오, 위 테스트하지 않았습니다.
정말 고마워요. 정말 도움이 .. – barsan
아무 문제 없습니다, 제발 upvote 및 나를 위해 허용 대답으로 표시 하시겠습니까? – hutchonoid
확실한 형제. 나는 이것을하고 싶다. :) – barsan