在datagrid模板列中,为了显示两行数据,我又写了一个table,但不知道如何用datagrid的items.cell(0).text取值啊,谢谢先~(有码)
<columns>
<asp:templatecolumn>
<itemstyle cssclass="onerowstyle" width=""></itemstyle>
<itemtemplate>
<table cellpadding="0" cellspacing="1" align="left">
<tr>
<td class="lyc_grid_textitem2_left">
<%# DataBinder.Eval(Container.DataItem, "新产品", "{0:c}") %>' />
</td>
<td class="lyc_grid_textitem2_left">
<%# DataBinder.Eval(Container.DataItem, "名", "{0:c}") %>' </td>
</tr>
</table>
</itemtemplate>
</asp:templatecolumn>
</columns>
当点击按钮时,如何取cell(0)里面的"新产品"和"名"的值啊~
问题点数:30、回复次数:11Top
1 楼AllenTing(今天你GC了吗???)回复于 2005-02-01 14:05:31 得分 15
table标签的不会,
你可以用两个asp:lable显示的,还要加上两个id;
可以以这样:
<columns>
<asp:templatecolumn>
<itemstyle cssclass="onerowstyle" width=""></itemstyle>
<itemtemplate>
<asp:lable id ="lable1" text = "<%# DataBinder.Eval(Container.DataItem, "新产品", "{0:c}") %> " runat="server"/>
<asp:lable id="lable2" text = "<%# DataBinder.Eval(Container.DataItem, "名", "{0:c}") %>" runat="server"/>
</itemtemplate>
</asp:templatecolumn>
</columns>
取之:
string str1=e.Item.FindControl("lable1").Text.ToString();
string str2=e.Item.FindControl("lable2").Text.ToString();Top
2 楼AllenTing(今天你GC了吗???)回复于 2005-02-01 14:07:16 得分 0
或者:<columns>
<asp:templatecolumn>
<itemstyle cssclass="onerowstyle" width=""></itemstyle>
<itemtemplate>
<table cellpadding="0" cellspacing="1" align="left">
<tr>
<td class="lyc_grid_textitem2_left">
<asp:lable id ="lable1" text = "<%# DataBinder.Eval(Container.DataItem, "新产品", "{0:c}") %> " runat="server"/>
</td>
<td class="lyc_grid_textitem2_left">
<asp:lable id="lable2" text = "<%# DataBinder.Eval(Container.DataItem, "名", "{0:c}") %>" runat="server"/>
</td>
</tr>
</table>
</itemtemplate>
</asp:templatecolumn>
</columns>
Top
3 楼AllenTing(今天你GC了吗???)回复于 2005-02-01 14:07:56 得分 0
这样就可以了,在td里面加上两个asp:lableTop
4 楼godblessyU(痛并快乐着!)回复于 2005-02-01 14:23:41 得分 0
我就是用LABEL解决的,而我发贴的目的是想知道如何用我上面提出的方法解决~谢谢~Top
5 楼web_gus(树欲静而风不止)回复于 2005-02-01 14:23:49 得分 0
看来只有顶了Top
6 楼godblessyU(痛并快乐着!)回复于 2005-02-02 23:55:39 得分 0
思归大哥哪我去了,帮帮忙啊~Top
7 楼kflash(狂闪工作室)回复于 2005-02-03 02:23:22 得分 0
((TextBox)DataGrid1.Items[0].Cell[0].foundControls["控件名称"]).Text.Trim()Top
8 楼godblessyU(痛并快乐着!)回复于 2005-02-03 08:46:49 得分 0
楼上的,首先谢谢你们给我的答复;
但我要实现的不是用控件,而是想用
<td class="lyc_grid_textitem2_left">
<%# DataBinder.Eval(Container.DataItem, "新产品", "{0:c}") %>' />
</td>
取值,难道没有解决的方法吗?Top
9 楼shanjinqi(dashan)回复于 2005-02-03 10:05:20 得分 0
点击什么按钮时取值???Top
10 楼guag(天知道)回复于 2005-02-03 11:35:36 得分 0
等待答案..搞了半小时没有能够弄出来...建议搂住是不是把要绑定的字段放在Label里面...这样要好找些..
还有在Debug时,可以看到那两个帮定的字段,但就是取不出来...期待高人..Top
11 楼guag(天知道)回复于 2005-02-03 11:42:06 得分 15
<table cellpadding="0" cellspacing="1" align="left">
<tr>
<td class="lyc_grid_textitem2_left">
<asp:Label ID="lbl1" Runat=server Text='<%# DataBinder.Eval(Container.DataItem, "a", "{0:c}") %>'></asp:Label>
</td>
<td class="lyc_grid_textitem2_left">
<asp:Label ID="lbl1" Runat=server Text='<%# DataBinder.Eval(Container.DataItem, "b", "{0:c}") %>
'></asp:Label>
</td>
</tr>
</table>Top




