asp.net GridVIew 编辑时候获取非编辑状态下控件的内容

来源:百度知道 编辑:UC知道 时间:2024/06/30 05:10:33
页面中有一GridView, 使用自带的编辑功能,点击编辑的时候,其中一个模板列的 编辑状态 是个DataList 绑定数据没问题,就是设置 SelectVlaue的时候 老是 空指针异常 我用的是((DropDownList)(GridViewUserList.Rows[inde].Cells[3].FindControl("DropDownListRoles"))).SelectedValue = ((Label)(GridViewUserList.Rows[inde].Cells[3].FindControl("Label3"))).Text; 其中inde 是当前编辑行的索引, 有没有好的办法能获取 GridVIew 在非编辑状态下显示的值
模板列 本来是文本也就是Label 编辑状态下,我用的DataList 用GridView.Rows[inde].Cells[3] 的形式获取的值为"" 空.

你说的是datalist嵌套吧 我举个例子 你看下 行不行

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:DataList ID="DataList1" runat="server" Width="463px"
onitemdatabound="DataList1_ItemDataBound">
<ItemTemplate>
<a href='newsList.aspx?id=<%# Eval("newstypeid")%>'><%#Eval("newstypeName") %></a> 
<br />

<asp:DataList ID="DataList2" runat="server">
<ItemTemplate>