我想GridView
用 aHyperLink
和其他两个字段填充。
我半心半意地尝试了以下方法。它给出了错误。
SqlCommand comm = new SqlCommand(
@"Select
FileUpload.FileName AS FileName,
FileUpload.FilePath AS PATH,
SubjectMaster.SubjectName AS Subject,
MemberPersonalInformation.FirstName As SharedBy
from FileUpload
INNER JOIN ContentManagement
ON ContentManagement.FileId=FileUpload.FileId
INNER JOIN MemberPersonalInformation
ON MemberPersonalInformation.MemberId=ContentManagement.CreatedBy
INNER JOIN SubjectMaster
ON ContentManagement.SubjectName=SubjectMaster.SubjectId
where
FileUpload.FileId in
(
Select FileId
from ContentManagement
where
ContentId in
(
Select ContentId
from ContentToIndividual
where ShowToMemberId=@MemberId
) and
ContentManagement.ContentTypeId=@TPD and
ContentManagement.SessionId=@SessionId
)", conn);
conn.Open();
SqlDataReader rdr = comm.ExecuteReader();
int i = 0;
while (rdr.Read())
{
string fip = rdr["PATH"].ToString();
GridViewRow di = GridView1.Rows[i];
HyperLink h1 = (HyperLink)di.FindControl("Hyperlink1");
h1.Text = rdr["FileName"].ToString();
h1.NavigateUrl = "download.aspx?filepath=" + fip;
di.Cells[1].Text = rdr["SharedBy"].ToString();
di.Cells[2].Text = rdr["Subject"].ToString();
i++;
}
rdr.Close();
获取错误消息
指数超出范围。必须是非负数且小于集合的大小。
参数名称:索引
如果有人建议我更好的方法来做到这一点或纠正这个错误,请。