How can i bind DetailsView
-
Hi all, I use DetailsView Object in ASP.NET. It dosen’t appear until the refresh button in IE clicks. I set the DataSource Property and use the DataBind Method. What i can do?
would you like to post your code with the event you are using to perform tis task?
Naveed Kamboh Complexity kills, Write easy code for your self. isolutionteam
-
would you like to post your code with the event you are using to perform tis task?
Naveed Kamboh Complexity kills, Write easy code for your self. isolutionteam
Hi This is my code asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" Height="40px"Style="direction: rtl" Width="472px" Fields asp:BoundField DataField="Employer" HeaderText="کارفرما" asp:BoundField DataField="Advisor" HeaderText="مشاور" asp:BoundField DataField="StartTime" HeaderText="زمان شروع" asp:BoundField DataField="EndTime" HeaderText="پیش بینی تاریخ اتمام پروژه" asp:BoundField DataField="TimeAgreement" HeaderText="مدت قرارداد به ماه" asp:BoundField DataField="State" HeaderText="محل اجرا" Fields asp:DetailsView> asp:SqlDataSource ID="SQLDS_ALLV_TitleIE" runat="server" ConnectionString="<%$ ConnectionStrings:SamanMohitConnectionString %>" SelectCommand="ALLV_TitleIE" SelectCommandType="StoredProcedure" SelectParameters asp:ControlParameter ControlID="Label1" Name="F_Title" PropertyName="Text" Type="String" asp:Parameter DefaultValue="فارسی" Name="F_Language" Type="String" SelectParameters asp:SqlDataSource I use the "<"and "/>" in my code And this is runtime code Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If (Application("SN") = "Agreement") Then Label1.Text = PreviousPage.mText1.Text DetailsView1.DataSource = SQLDS_ALLV_TitleIE DetailsView1.DataBind() ElseIf (Application("SN") = "News") Then Label3.Text = PreviousPage.mText1.Text DetailsView2.DataSource = SQLDS_NL_Title DetailsView2.DataBind() End If LinkButton1.CommandName = Application("Search") End Sub -- modified at 0:48 Sunday 8th April, 2007
-
Hi This is my code asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" Height="40px"Style="direction: rtl" Width="472px" Fields asp:BoundField DataField="Employer" HeaderText="کارفرما" asp:BoundField DataField="Advisor" HeaderText="مشاور" asp:BoundField DataField="StartTime" HeaderText="زمان شروع" asp:BoundField DataField="EndTime" HeaderText="پیش بینی تاریخ اتمام پروژه" asp:BoundField DataField="TimeAgreement" HeaderText="مدت قرارداد به ماه" asp:BoundField DataField="State" HeaderText="محل اجرا" Fields asp:DetailsView> asp:SqlDataSource ID="SQLDS_ALLV_TitleIE" runat="server" ConnectionString="<%$ ConnectionStrings:SamanMohitConnectionString %>" SelectCommand="ALLV_TitleIE" SelectCommandType="StoredProcedure" SelectParameters asp:ControlParameter ControlID="Label1" Name="F_Title" PropertyName="Text" Type="String" asp:Parameter DefaultValue="فارسی" Name="F_Language" Type="String" SelectParameters asp:SqlDataSource I use the "<"and "/>" in my code And this is runtime code Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If (Application("SN") = "Agreement") Then Label1.Text = PreviousPage.mText1.Text DetailsView1.DataSource = SQLDS_ALLV_TitleIE DetailsView1.DataBind() ElseIf (Application("SN") = "News") Then Label3.Text = PreviousPage.mText1.Text DetailsView2.DataSource = SQLDS_NL_Title DetailsView2.DataBind() End If LinkButton1.CommandName = Application("Search") End Sub -- modified at 0:48 Sunday 8th April, 2007
سلام اگر فارسی می نویسیم به این دلیل است که از نوع عناوین جنابعالی فهمیدم که ایرانی هستید. به هر حال برای Bind کردن DetailsView با این روشی که شما انتخاب کرده اید و از SqlDataSource استفاده می کنید، برای گرفتن نتیجه باید از DetailsView1.DataSourceId استفاده کنید درضمن هنگام تعریف DetailsView میتوانید در کد های HTML نیز این مشخصه را تعیین نمایید برای مثال: asp:DetailsView ID="dtl1" DataSourceId="SQLDS_ALLV_TitleIE" runat="server" ..... /asp:DetailsView در ضمن بهتر است دستور Select شما حاوی شرطی باشد که موجب برگرداندن یک رکورد شود. اگر هم با SqlDataSource مشکل دارید می توانید از DataTable استفاده کنید. ال