0
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField HeaderText="FileName">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="" Text=""></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
aspx.cs文件動態添加行到GridView在ASP.NET(C#)
SqlCommand comm = new SqlCommand(Select
FileUpload.FileName AS FileName,
FileUpload.FilePath AS PATH,
SubjectMaster.SubjectName AS Subject,
MemberPersonalInformation.FirstName As SharedBy
from FileUpload",conn)
我需要打印FileName(As Hyperlink)
,SharedBy
,Subject
在網格我該怎麼辦呢?
我需要做這樣的事情......但低於做法不工作
conn.Open();
SqlDataReader rdr = comm.ExecuteReader();
int i = 0;
while (rdr.Read())
{
string fip = rdr["PATH"].ToString();
HyperLink h1 = (HyperLink)GridView1.Rows[i].Cells[0].FindControl("Hyperlink1");
h1.Text = rdr["FileName"].ToString();
h1.NavigateUrl = "download.aspx?filepath=" + fip;
GridView1.Rows[i].Cells[1].Text = rdr["SharedBy"].ToString();
GridView1.Rows[i].Cells[2].Text = rdr["Subject"].ToString();
GridView1.Rows[i].Cells[3].Text = rdr["PATH"].ToString();
//GridView1.Rows[i].Rows.Add(di);
i++;
}
我不明白你在說什麼?實際上我需要在.cs文件中編碼 – Naresh 2011-06-16 07:55:55
編輯我的響應.cs – Atzoya 2011-06-16 08:22:52
爲什麼要在代碼後面設置? – 2011-06-16 08:29:34