我想從GridView的單元格的值,但空字符串返回。我是在執行的RadioButtonList的SelectedIndexChanged事件
代碼通過gridview的 和接入小區的代碼。我重複。但問題是stll remaining.I使用了三個ItemTemplate中,每個 有一個elemnt使每個元素獲得自己的coulmn的.aspx獲取標籤文本
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false" >
<Columns>
<asp:TemplateField>
<itemtemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("qno") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("description")
%>'>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<itemtemplate>
<asp:RadioButtonList ID="RadioButtonList1" RepeatDirection="Horizontal"
runat="server" OnSelectedIndexChanged="changed" AutoPostBack="true" >
<asp:ListItem Value="agree" Selected="True" >
</asp:ListItem>
<asp:ListItem
Value="disagree">
</asp:ListItem>
<asp:ListItem Value="strongagree">
</asp:ListItem>
<asp:ListItem Value="strondisagree">
</asp:ListItem>
</asp:RadioButtonList>
</itemtemplate>
</templatefield>
</Columns>
</asp:GridView>
<asp:Label ID="Labe11" runat="server" ></asp:Label>
Code behind: public void changed(object sender, EventArgs e) {
for(int i=0;i<GridView2.Rows.Count;i++)
{
string labtext;
RadioButtonList list =
GridView2.Rows[i].Cells[2].FindControl("RadioButtonList1") as RadioButtonList;
labtext= GridView2.Rows[i].Cells[0].Text;
Label1.Text = labtext;
}
}
我已經使用單獨的但問題依舊 –
user1405508