3
嗨我有一個GridView,我想以提取PhotoPath(ftppath +文件名(ftp://192.168.1.2/Jelly.jpg))C#從GRIDVIEW讀取數據串
其在asp.net並且我不確定如何檢索數據。我將gridView設置爲可供選擇,並且我喜歡「選擇」將PhotoPath存儲在字符串中。
源
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="StudentID"
DataSourceID="SqlDataSource1" Height="263px" Width="915px"
AllowPaging="True" CellPadding="4" ForeColor="#333333" GridLines="None"
onselectedindexchanged="GridView1_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
ShowSelectButton="True" />
<asp:BoundField DataField="No" HeaderText="MatricNo"
SortExpression="MatricNo" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName"
SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName"
SortExpression="LastName" />
<asp:BoundField DataField="Current" HeaderText="CurrentModules"
SortExpression="CurrentModules" />
<asp:BoundField DataField="PhotoPath" HeaderText="PhotoPath"
SortExpression="PhotoPath" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" BorderColor="Blue" BorderStyle="Solid"
Font-Size="Small" />
<SelectedRowStyle BackColor="#D1DDF1" BorderStyle="Solid" Font-Bold="True"
Font-Size="Small" ForeColor="#333333" HorizontalAlign="Center" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
我tryed這一點:
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
string PhotoPath;
GridView1.CurrentRow.Cells[0].Value.ToString();
}
但是當前行不是定義的一部分。
非常感謝:)得到一個小錯誤與NewSelectedIndex壽錯誤 'System.EventArgs' 不包含定義 'NewSelectedIndex' 和沒有找到接受'System.EventArgs'類型的第一個參數的擴展方法'NewSelectedIndex'(您是否缺少使用指令或程序集引用?) – 2010-12-05 03:08:44