On Jul 26, 11:13 pm, Sebastian <doug4k...@web. dewrote:
Hello!
I have bound a DataTable to my GridView. The DataTable has 3 Columns and
I display the Data with TemplateFields in my GridView. I have in the
first Column "LinkButton " - Field and in the other two Columns I have
"Label" - Fields!
How can I retrieve the Data of the third Column, when I click the
"LinkButton " from the same row?
I hope anyone could help me!
Here is the code from my GridView...
<asp:GridView ID="gdvData" runat="server" AutoGenerateCol umns=False
CellPadding="6" ForeColor="#333 333"
Style="left: 0px; position: relative; top: 25px" >
<Columns>
<asp:TemplateFi eld HeaderText="Nam e" >
<ItemTemplate >
<asp:LinkButt on ID="lkbName" runat="server"
Text='<%#Eval(" Name")%>' OnClick="LinkBu tton_Click"/>
</ItemTemplate>
<ItemStyle HorizontalAlign ="Center" />
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Ers tellt am" >
<ItemTemplate >
<asp:Label ID="lblCreation Time" runat="server"
Text='<%#Eval(" Erstellt am", "{0:d}")%>'/>
</ItemTemplate>
<ItemStyle HorizontalAlign ="Center" />
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Ful lName" >
<ItemTemplate >
<asp:Label ID="lblFullName " runat="server"
Text='<%#Eval(" Pfad")%>'/>
</ItemTemplate>
<ItemStyle HorizontalAlign ="Center" />
</asp:TemplateFie ld>
</Columns>
</asp:GridView>
Regards
Sebastian
Hi Sebastian,
I have made a few changes to your provided code... and made worked
exactly what you want ...
<asp:TemplateFi eld HeaderText="Nam e">
<ItemTemplate >
<asp:LinkButt on ID="lkbName" runat="server"
Text='<%#Eval(" Name")%>' CommandName="Se lect" CommandArgument ='<
%#Eval("Id")%>' />
</ItemTemplate>
<ItemStyle HorizontalAlign ="Center" />
</asp:TemplateFie ld>
in the above code you can see that i have add commandname and
commandargument ...
after that i subscripted the rowcommand event of the gridview...
and in rowcommand event handler... i did
protected void gdvData_RowComm and(object sender,
GridViewCommand EventArgs e)
{
if (e.CommandName == "Select")
{
GridViewRow row =
gdvData.Rows[Convert.ToInt32 ( e.CommandArgume nt)];
Label lbl = (Label) row.FindControl ("lblFullName") ;
string name = lbl.Text;
}
}
worked very well for me...
please give a try...
Thanks
Md. Masudur Rahman (Munna)
Kaz Software Ltd.
www.kaz.com.bd http://munnacs.110mb.com