我有一个像这样定义的gridview ......
<asp:GridView runat="server" id="gvProjectLineage"
ShowFooter="false"
DataKeyNames="projectLineageID"
AutoGenerateColumns="False"
AllowPaging="false"
AllowSorting="false"
RowStyle-CssClass="shade" CellSpacing="1"
AlternatingRowStyle-CssClass="unshade"
BorderColor="Transparent"
DataSourceID="gvProjectLineageDataSource"
Width="100%">
<HeaderStyle HorizontalAlign="Left" Font-Underline="true"></HeaderStyle>
<Columns>
<asp:BoundField ReadOnly="True"
HeaderText="Lineage ID"
InsertVisible="false"
DataField="projectLineageID"
HeaderStyle-CssClass="columnHeader"
ItemStyle-VerticalAlign="Top"
Visible="false">
</asp:BoundField>
<asp:BoundField ReadOnly="True"
HeaderText="Relationship type"
InsertVisible="false"
DataField="projectRelationshipType"
HeaderStyle-CssClass="columnHeader"
ItemStyle-VerticalAlign="Top"
Visible="true">
</asp:BoundField>
<asp:BoundField ReadOnly="True"
HeaderText="Related Project"
InsertVisible="false"
DataField="projectTitle"
HeaderStyle-CssClass="columnHeader"
ItemStyle-VerticalAlign="Top"
Visible="true">
</asp:BoundField>
<asp:TemplateField ShowHeader="False"
HeaderStyle-Font-Underline="false"
ItemStyle-HorizontalAlign="Left"
FooterStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:LinkButton ID="btnDelete"
CommandArgument='<%# Eval("projectLineageID") %>'
CommandName="Delete"
runat="server">
<img style="border:none;"
src="/content/images/icon/deleteIcon.png"
title="Delete this lineage" />
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False"
HeaderStyle-Font-Underline="false"
ItemStyle-HorizontalAlign="Left"
FooterStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:LinkButton ID="btnDeleteAll"
CommandArgument='<%# Eval("projectLineageID") %>'
runat="server"
OnClick="btnDeleteAll_Click" >
<img style="border:none;"
src="/content/images/icon/deleteIcon.png"
title="Delete this lineage AND it's reciprocal lineage" />
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>There are currently no relationships identified for this S&T project.</EmptyDataTemplate>
</asp:GridView>
第一个&#34;删除&#34;按钮调用一个简单的删除查询,它可以正常删除表中选定的行。但是,当我调用第二个删除按钮(&#34; DeleteAll&#34;)时,我想使用[projectLineageID]查找项目的相关沿袭记录并一次删除它们。
当我拨打第二个删除功能&#34; onclick&#34;如下所示,我在[0]栏中得不到任何结果。
protected void btnDeleteAll_Click(object sender, EventArgs e)
{
//Delete lineage and reciprocal lineage for relationship types 1 (Transitioned from) and 2 (Transitioned to)
util u = new util();
GridViewRow grdrow = (GridViewRow)((LinkButton)sender).NamingContainer;
string strRelID = grdrow.Cells[0].Text;
int intRelID = System.Convert.ToInt32(grdrow.Cells[0].Text);
string relType = grdrow.Cells[1].Text;
string relProj = grdrow.Cells[2].Text;
Response.Write ("Deleting relationship between " + projectID + " and the project in column 3 " + relID + " " + relType + " " + relProj + " :");
}
如何让projectLineageID将其传递给查询? 而且,为什么我无法显示它?即使我试图&#34;转换&#34;它,我收到一个错误,告诉我&#34;输入字符串的格式不正确。&#34;
谢谢, 鲍勃