我想以這種方式顯示gridview中的值(圖像),我如何執行它,我不知道,如果我必須編輯列或添加模板字段。 ,請幫忙。 如果我們添加一個頁腳,它只能顯示在最後一行,但是,如何使它顯示在中間。當綁定到數據源時自定義gridview顯示
1
A
回答
0
我想你需要做的跨越有這個樣子的列。 (我假設你有所有需要綁定到控件的數據。)
0
您可以使用Gridview Footer進行此顯示。
<asp:TemplateField>
<FooterTemplate>
<table>
<tr>
<td>
<asp:Label ID="lblname" runat="server" Text="NAME"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtbx" runat="server"></asp:TextBox>
</td>
</tr>
</table>
</FooterTemplate>
</asp:TemplateField>
在RowDataBound事件上,您可以將總數設置爲標籤。
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lbl = (Label)e.Row.FindControl("lblTotal");
lbl.Text = "Total";
}
}
2
你會使用的東西就像一個Repeater
或DataList
控制,這讓您欣賞到更加輸出控制會更好。
+0
好的解決方案作爲中繼器會給你一個非常好的控制設計,因爲它不會留下任何跡象,就像我們在網格和數據列表中 –
2
<asp:GridView runat="server" ID="gdv" AutoGenerateColumns="false" Width="100%">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table width="100%">
<tr>
<td>
Exam Date
</td>
<td>
<%#Eval("Exam_Date") %>
</td>
<td>
Section
</td>
<td>
<%#Eval("Section") %>
</td>
</tr>
<tr>
<td>
Total Students
</td>
<td>
<%#Eval("Total_Students") %>
</td>
<td>
No. of students passed
</td>
<td>
<%#Eval("StudentPassed") %>
</td>
</tr>
<tr>
<td colspan="2">
over all pass percentange
</td>
<td colspan="2">
<%#Eval("Overall_Percent") %>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
在CS頁:
gdv.DataSource = YourDataSource;
gdv.DataBind();
相關問題
- 1. 自定義排序對象數據源綁定gridview
- 2. GridView不綁定數據源
- 3. 獲取rowdata綁定到gridview數據源
- 4. 動態數據源綁定到GridView
- 5. asp.net gridview排序自定義數據源
- 6. asp.net gridview自定義數據源
- 7. 列綁定到gridview時沒有顯示使用linq to sql與空數據源
- 8. 自定義或動態數據綁定到GridView控件
- 9. 數據綁定RadioButtonList綁定,但現在顯示在GridView中
- 10. 綁定數據到GridView
- 11. 數據綁定到GRIDVIEW
- 12. 來自綁定源的數據綁定
- 13. 數據綁定到自定義的DataGridView
- 14. Winforms數據綁定到自定義類
- 15. 數據綁定到自定義UserControl
- 16. 將數據綁定到gridview時出錯
- 17. 綁定資源數據到自定義winjs控件
- 18. 使用用於綁定到Gridview的元數據的自定義數據表?
- 19. 數據源自動綁定
- 20. 從多個數據源綁定GridView
- 21. WPF:綁定到自定義類「無法綁定找到源」
- 22. Gridview數據綁定
- 23. 在Winforms中綁定到數據源的gridview的bool列中顯示yes/no?
- 24. 當使用GridView時,最好的選擇是將它綁定到數據源上?
- 25. 將數據表綁定到Gridview - 不顯示在網頁上
- 26. 將數據綁定到gridview不顯示網格asp
- 27. 當數據源沒有數據時,自定義UIPickerView崩潰
- 28. WPF GridView - 動態綁定自定義類
- 29. ASP.NET GridView自定義綁定錯誤
- 30. GridView綁定顯示參數不正確
謝謝你,可是,我們怎麼辦?你能提供一個例子嗎? – user2740323