在下面的代碼中,我有一個DataGrid,得到特定行的標識中,我有2列userid
和documentid
和一個按鈕。 我想得到userid
的特定行,我該怎麼做?要在數據網格
<asp:DataGrid Width="100%" ID="DocumentUsergrid"
PagerStyle-Mode="NumericPages" PageSize="10" PagerStyle-Visible="true"
AllowPaging="true" AllowSorting="true"
AlternatingRowStyle-CssClass="alt">
<AlternatingItemStyle BackColor="White" />
<asp:TemplateColumn HeaderText="DocumentID" ItemStyle-Width="150px" Visible="false" >
<ItemTemplate>
<asp:Label ID="lblOutputProductID_i" runat="server" Text='<%#Eval("DocumentID") %>' > </asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="UserID" ItemStyle-Width="150px" Visible="false" >
<ItemTemplate>
<asp:Label ID="lblSupportProductID_i" runat="server" Text='<%#Eval("UserID") %>' > </asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Insert" ItemStyle-Width="150px">
<ItemTemplate>
<asp:Button ID="btnSubmit" runat ="server" OnClick="btnSubmit_Click" />
</ItemTemplate>
</Columns>
<HeaderStyle Font-Bold="True" ForeColor="White" />
<ItemStyle BackColor="#EFF3FB"/>
</asp:DataGrid>
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
Dictionary<string, string> OutputProductVal = new Dictionary<string, string>();
OutputProductVal.Add("UserID",);//To get userid of particular row
OutputProductVal.Add("DocumentID", ddlDocumentName.SelectedValue.ToString());
DocumentServiceClient oProduct = new DocumentServiceClient();
oProduct.InsertUserDocumentMap(OutputProductVal);
}
}
我使用數據網格不GridView控件的 – user3729162
可能的複製http://stackoverflow.com/questions/5121186/datagrid-get-selected-rows-column-values –