الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

Click On Row At Datalist

بدأه Eng.Fedail في 15 أغسطس 2008 · 5 رد · 618 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

i was bindidg data to datalist and when user click on text i want to show another data at label but i have an error on explorer

can u explain me how can i make an event on this example

 

<script language="vbscript" runat="server"> 


Public Sub information() 
' Dim ds As New Data.DataSet

' ds = DAL_config.getmenu

Label1.Text = "HI" 'ds.Tables(0).Rows(0)(1)

End Sub



</script>

<div id="panel">

<div id="right">



<asp:DataList CssClass="menu" ID="menu" runat="server" >

<ItemTemplate>

<p onclick="information()"><%#Eval("m_name")%></p>

</ItemTemplate>

</asp:DataList>

</div>

<div id="left">

<img id="Img1" alt="" src="images\banar\show.jpg" runat="server" />

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

</div>

</div>

and this is the vb code of page

Partial Class _Default 
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadDim ds As Data.DataSet = DAL_config.getmenu() 
menu.DataSource = ds

menu.DataBind()

End Sub 
End Class

joseph.gif

logo.gif

CCNA 640-802

مدونتي

#2

ok what you need to do is to handle the SELECT Event on the DataList i think its called

ItemCommand or SelectCommand

then have a LinkButton or a Command button with the property CommanName="Select"

this way you handle the selection of the Item on the datalist in the appropriate manner.

putting an onclick on a <p> will not do this

let me know if you need any more help.

#3

i haven't any idea about this way

can u show me example

but do u know the idea

the idea is i want to put at datalist text from db

and wen it clicked the another label or datalist is change the content

but let this in ur minde there is no that property u tell me in asp:datalist and i don't want to use command and link

and i want to use function with my way

joseph.gif

logo.gif

CCNA 640-802

مدونتي

#4

you have to use a postback control to do this unless you want to use javascript.

the easiset way is to have this on the webform

<asp:DataList ID="DataList1" runat="server">
            <ItemTemplate>
                <asp:LinkButton ID="btnSubmit" Text='<%#Eval("m_name")%>' CommandName="Select" CommandArgument='<%#Eval("m_name")%>'
                    runat="server" />
            </ItemTemplate>
        </asp:DataList>

    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

and in the code

  Protected Sub DataList1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles DataList1.ItemCommand

	Label1.Text = e.CommandArgument

   End Sub
#5

i have this problem

Control 'ctl00_ContentPlaceHolder1_menu_ctl00_btnsubmit' of type 'LinkButton' must be placed inside a form tag with runat=server.

i solve this problem when i put the form tag i want to work without form

and i want to tell u thanks from my heart

تم تعديل هذه المشاركة بواسطة السـاحر في 17 أغسطس 2008 في 15:31

joseph.gif

logo.gif

CCNA 640-802

مدونتي

#6

i want ur think about this method i write on

 Protected Sub menu_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles menu.ItemCommand
		Dim ds As Data.DataSet = DAL_config.getmenu()
		Label1.Text = ds.Tables(0).Rows(e.CommandArgument - 1)(2)


	End Sub

or there is another way

joseph.gif

logo.gif

CCNA 640-802

مدونتي

مواضيع مشابهة