what is in the SelectedItem.Cells[3]? are you sure it is plain text, showy your template, you might need to doLabel lbl = (Label)SelectedItem.Cells[3].Controls[0]; string s = lbl.Text;or add a control<ItemTemplate><asp:Label id="lbl" runat="server" Text='<%# ..... %>' /></ItemTemplate> then useLabel lbl = (Label)SelectedItem.FindControl("lbl"); string s = lbl.Text;
string s = lbl.Text;or add a control<ItemTemplate><asp:Label id="lbl" runat="server" Text='<%# ..... %>' /></ItemTemplate>
then useLabel lbl = (Label)SelectedItem.FindControl("lbl");
string s = lbl.Text;
你用FindControl吧。
SelectedItem.Cells[3].Text;
<asp:datagrid id="ProAuditData" style="Z-INDEX: 102" runat="server" Width="780px" Font-Names="宋体" Font-Size="12px" BorderWidth="1px" HorizontalAlign="Center" BackColor="White" BorderColor="#CC9966" BorderStyle="None" AutoGenerateColumns="False" CellPadding="2">
<SelectedItemStyle Font-Bold="True" ForeColor="#663399" BackColor="#FFCC66"></SelectedItemStyle>
<ItemStyle ForeColor="#330099" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" Wrap="False" HorizontalAlign="Center" ForeColor="#FFFFCC" VerticalAlign="Middle" BackColor="#990000"></HeaderStyle>
<FooterStyle Wrap="False" ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle>
<Columns>
<asp:ButtonColumn Text="编辑" HeaderText="编辑" CommandName="Select">
<HeaderStyle Width="30px"></HeaderStyle>
</asp:ButtonColumn>
<asp:ButtonColumn Text="删除" HeaderText="删除" CommandName="Delete">
<HeaderStyle Width="30px"></HeaderStyle>
</asp:ButtonColumn>
<asp:BoundColumn DataField="委托编号" HeaderText="委托编号">
<HeaderStyle Width="60px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="建设单位" HeaderText="建设单位" DataFormatString="<DIV style='overflow: hidden;width: 110px;'>{0}</DIV>">
<HeaderStyle Width="120px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="施工单位" HeaderText="施工单位" DataFormatString="<DIV style='overflow: hidden;width: 110px;'>{0}</DIV>">
<HeaderStyle Width="120px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="建设项目" HeaderText="建设项目" DataFormatString="<DIV style='overflow: hidden;width: 110px;'>{0}</DIV>">
<HeaderStyle Width="120px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="单位工程" HeaderText="单位工程" DataFormatString="<DIV style='overflow: hidden;width: 110px;'>{0}</DIV>">
<HeaderStyle Width="120px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="送审金额" HeaderText="送审金额" DataFormatString="{0:c}">
<HeaderStyle Width="100px"></HeaderStyle>
<ItemStyle Wrap="False" HorizontalAlign="Right" VerticalAlign="Middle"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="送审日期" HeaderText="送审日期">
<HeaderStyle Width="65px"></HeaderStyle>
</asp:BoundColumn>
</Columns>
<PagerStyle NextPageText="下一页" PrevPageText="上一页" HorizontalAlign="Center" ForeColor="#330099" BackColor="#FFFFCC" Wrap="False"></PagerStyle>
</asp:datagrid>
后台代码如下:
private void ProAuditData_SelectedIndexChanged(object sender, System.EventArgs e)
{
string sub=ProAuditData.SelectedItem.Cells[3].Text;
string construct=ProAuditData.SelectedItem.Cells[4].Text;
}可sub,construct始终为空,请各帮助解决,急
我信箱是: [email protected]