.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

i want to show data in textbox from tha datalist when user click any row

Posted By: pooja     Posted Date: June 30, 2011    Points:5   Category :ASP.Net
Dear All pls check this code and tell where the error
i m populate datalist and when click the user on datalist row
then show the selected item on textbox
pls check this

protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "Edit")
{

LinkButton id = (LinkButton)e.Item.FindControl("lnk");
Label c_type = (Label)e.Item.FindControl("cat");
TextBox1.Text = id.Text;
TextBox2.Text = c_type.Text;
}
}


and my source code is

<body>
<form id="form1" runat="server">
<div>

<asp:DataList ID="DataList1" runat="server" DataKeyField="ID"
DataSourceID="AccessDataSource1">
<ItemTemplate>


<asp:LinkButton ID ="lnk" runat ="server" CommandName="edit" Text='<%# Eval("ID") %>' />

<asp:Label ID="cat" runat="server" Text='<%# Eval("cat_type") %>' />
<br />
<br />
</ItemTemplate>
</asp:DataList>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/blog.mdb" SelectCommand="SELECT * FROM [content]">
</asp:AccessDataSource>

<br />

</div>
</form>
</body>



Responses
Author: Gowthammanju             
Posted Date: June 30, 2011     Points: 20   

hey please check out this project

http://www.dotnetspark.com/kb/660-how-to-get-selected-row-data-from-datalist.aspx


u will find solution

Thanks & Regards,
GowthamManju
Chennai



Mark if the answer is true


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend