这是我的标记: -
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Width="245px" onrowcommand="GridView1_RowCommand" >
<Columns>
<asp:TemplateField>
<ItemStyle BackColor="#CCCCCC" ForeColor="Black" Width="250px" HorizontalAlign="Center"
BorderStyle="None" />
<ItemTemplate>
<asp:LinkButton ID="userList" runat="server" CommandName="Select" CommandArgument ='<%# Container.DataItemIndex %>' Text='<%# Bind("users") %>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Run Code Online (Sandbox Code Playgroud)
在代码隐藏中,我试图获取当前行的文本值,但似乎无法得到它;
它返回"".
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int rowValue = Convert.ToInt32(e.CommandArgument.ToString());
GridView1.SelectedIndex = rowValue;
string test = GridView1.SelectedRow.Cells[0].Text;
}
Run Code Online (Sandbox Code Playgroud) 我想删除文件夹中的所有文件: -
import java.io.*;
public class AddService {
public static void main(String args[]){
File folder=new File("inputs");
File[] listOfFiles=folder.listFiles();
for(File file:listOfFiles){
if(file.delete())
System.out.println("File deleted");
else
System.out.println("File not deleted");
}
}
}
Run Code Online (Sandbox Code Playgroud)
我收到回复"文件未删除",文件没有被删除.我的代码出了什么问题?