Search code examples
asp.netdatalist

Using DataList control to redirect user on other page and fetch data on that page depending on the button clicked in previous page


I am using a datalist control in which i have a div and some other asp controls. I have an edit button in it. If I click on edit button, I want to redirect user to another page on which I have some controls and I want information to be filled up in those controls depending upon the button I have clicked in previous page.

Here is the datalist code:

<asp:DataList ID="DataList1" runat="server" DataKeyField="ID" RepeatColumns="2" RepeatDirection="Horizontal" RepeatLayout="Table">


        <ItemTemplate>
          <div><br /><br /><br />
          <div style="background-color:Silver;height: auto; display:block;" >

                <div id="threadPostLeftDiv" style="width:auto; border-style:solid; border-width:2px; border-color:Black;border-right-color:White;" >
                <asp:Image runat="server" ID="ImagePreview1" style="margin-right:5px; " ImageUrl='<%# Eval("imageurl") %>' Height="100px" Width="100px" BorderStyle="None" />

                </div>
                <div id="threadPostRightDiv" style=" border-style:solid; border-width:2px;margin-left:-15px; border-color:Black;border-left-color:White;">


                    <asp:Label ID="txtHeadline1"  CssClass="inputprev" style=" font-size:medium; font-weight:bolder;"   Text='<%# Eval("subtitle") %>' Enabled="false"
                        placeholder="Headline" runat="server"></asp:Label>
                    <br />

                    <asp:Textbox ID="txtDescription1"  CssClass="inputprevdesc1"  Text='<%# Eval("descriptions") %>'
                        Enabled="false" BackColor="Silver" Rows="3" TextMode="MultiLine" placeholder="Description"  runat="server"></asp:Textbox><br />
                    <br />

                    <asp:Label ID="txtOfferHeadline1" Text='<%# Eval("title") %>' Enabled="false"  CssClass="inputprev1" 
                         placeholder="Offer Headline" runat="server"></asp:Label>
                     <br />
                </div>

          </div>
                <div style=" float: right;margin-right:10px; ">
                 <button id="btnEdit"  class="css3button1" onserverclick="btnEdit_Click" runat="server">Edit</button>

                </div>

          </div>
</asp:DataList>

Please help me in acheiving my goal,give me the code behind file and what events to triggers. Thank you.


Solution

  • I converted html button to link button and fired onRowCOmmand event and I got my solution.