Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 this is the my source code

<pre lang="xml"><body>
    <form id="form1" runat="server">
    <div>

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

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


                <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>
Posted
Comments
[no name] 30-Jun-11 8:10am    
Are you getting any errors? Is this not working? Do you just want a code review?
shilpa-pandit 30-Jun-11 8:46am    
here not error page post back without any error and data not show in textbox

1 solution

write that code in item command event of datalist
 
Share this answer
 
Comments
shilpa-pandit 30-Jun-11 9:56am    
dear sir
pls give me example

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900