Pregunta

He creado un control SpGridView en mi parte visual web.Dentro de SpGridView, hay un control Sphyperlink que almacena alguna URL. Al acceder a este valor usando SpGridView sothedrow.cells [3] .text, estoy obteniendo un valor vacío.

spgridview control

<SharePoint:SPGridView ID="ShowNode" runat="server" AutoGenerateColumns="false" 
        AllowSorting="true" OnRowDataBound="ShowNode_RowDataBound" OnSelectedIndexChanged="ShowNode_RowIndexChanged" OnSorting="ShowNode_Sort" OnRowCommand="ShowNode_RowClick">
<Columns>
<asp:ImageField HeaderText="Icon"  DataImageUrlField="Img" HeaderStyle-HorizontalAlign="Left"></asp:ImageField>
<SharePoint:SPBoundField HeaderText="Name" DataField="Title" HeaderStyle-HorizontalAlign="Left" SortExpression="Name"/>
<SharePoint:SPBoundField HeaderText="Type" DataField="Type" HeaderStyle-HorizontalAlign="Left" SortExpression="Type" />
<asp:HyperLinkField  DataTextField="Link" HeaderText="Link" Visible="false" HeaderStyle-HorizontalAlign="Left"/>
</Columns>
</SharePoint:SPGridView>

fila Haga clic en evento

protected void ShowNode_RowIndexChanged(object sender, EventArgs e)
        {
            int ind = ShowNode.SelectedRow.RowIndex;
            string link = ShowNode.SelectedRow.Cells[3].Text;


        }

¿Fue útil?

Solución 2

Pude obtener los valores utilizando el atributo DataKeyy SpgridView.

Gridview Control

<SharePoint:SPGridView ID="ShowNode" runat="server" AutoGenerateColumns="false" AllowSorting="true" ShowFooter="true"  ShowHeader="true" DataSourceID="" DataKeyNames="Link,Type" OnRowDataBound="ShowNode_RowDataBound" OnSelectedIndexChanged="ShowNode_RowIndexChanged" OnSorting="ShowNode_Sort"  EnableViewState="true" >

<Columns>

<asp:ImageField HeaderText="Icon"  DataImageUrlField="Img" HeaderStyle-HorizontalAlign="Left">

</asp:ImageField><SharePoint:SPBoundField HeaderText="Name" DataField="Name" HeaderStyle-HorizontalAlign="Left" SortExpression="Name"/>

<SharePoint:SPBoundField HeaderText="Type" DataField="Type" HeaderStyle-HorizontalAlign="Left"  />

<asp:HyperLinkField  DataTextField="Link" HeaderText="Link" Visible="false" HeaderStyle-HorizontalAlign="Left"/>

</Columns> 

</SharePoint:SPGridView>

código detrás

string u= ShowNode.DataKeys[ShowNode.SelectedRow.RowIndex]["Link"].ToString(); 

string t = ShowNode.DataKeys[ShowNode.SelectedRow.RowIndex]["Type"].ToString();

Otros consejos

Intente eliminar la propiedad "Visible= False" del campo de hipervínculo y luego verifique, no debe devolver el valor vacío y luego.

Estoy recibiendo valor en mi lado.Intenta depurarlo y ver en la ventana "Shift + F9" Navegue allí, ya que esto le ayudará a encontrar un valor de un control en particular.

Licenciado bajo: CC-BY-SA con atribución
scroll top