Category Archives: DetailsView

DetailsView

[RESOLVED]Can't find control inside a detailsview

Hi all,

Background:

Site that uses master pages

In a content page I have a detailsview control containing many controls – textboxes, labels, dropdowns etc.

Detailsview has Template fields with item and edititem templates

I want to access the value of a label within an itemtemplate field.

Outline:

"Head" ContentPlaceholder 
    "Main" ContentPlaceholder 
         Bootstrap Row
           .... 
         End Bootstrap Row 

         Bootstrap Row 
           <div> 
              DetailsView 
                 Fields 
                    TemplateField 
                       ItemTemplate 
                           Label ID="registrationID" -- THIS IS CONTROL THAT CONTAINS THE VALUE I WANT 
                       End ItemTemplate 
                       EditItemTemplate 
                           Textbox 
                       End EditItemTemplate
                         . . . . 
         [END TAGS]

In Javascript

var regIdText = $('#' + '<%= registrationID.ClientID %>').val();

But I get an error saying registrationID is not declared.

I tried adding a css class to the label and selecting it that way but it failed as well.

Any ideas?

Becuase the registrationID control is nested within the template you won’t be able to access it outside that ItemTemplate.

What you can try is on that Label control add the attribute ClientIDMode="Static".  Then in your javascript change:

var regIdText = $('#' + '<%= registrationID.ClientID %>').val();

To

var regIdText = $('#registrationID').val();

Hi SeeDosRun,

Thanks for your post.

ASP.NET allows certain controls to be denoted as naming containers. A naming container serves as a new ID namespace. Any server controls that appear within the naming container have their rendered id value prefixed with the ID of the naming container control.
In this situation, you should visit the page through a browser and view the HTML source to check the id of the Label then get the value according to correct id.

For more information about “Control ID Naming in Content Pages”, you could refer to the below link.

Hope it will be helpful to you.

Best Regards,

Fei Han

Thanks for you suggestions.

I ended up using

$("[id$='registrationID']").text();

that way I don’t have to worry about naming containers.

Thanks again.

[RESOLVED]ASP. NET c# and Jquery – value of selected item is gone after maincontent is filled

I have the following problem. When I select an item <li> which references to the ~/About.aspx. Then the value of the selected Item is gone. It is there when I alert the .click function. But it is gone after the document.ready function. Why does it not work
and what do I need to change. I store the value in a hiddenfield. But also this value is being resetted.

Clicking the (about) <li> shows nicely the selected item is 1. But after loading the content into the maincontent the value is gone! What do I need to do. I have searched the entire web but I cannot find a similar problem.

Best regards,
Monty

The code:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="Monitoring.SiteMaster" %>

<!DOCTYPE html>
<html lang="en">
<head runat="server">
<meta charset="utf-8" />
<title><%: Page.Title %> - My ASP.NET Application</title>
<asp:PlaceHolder runat="server"> 
<%: Scripts.Render("~/bundles/modernizr") %>
</asp:PlaceHolder> 
<webopt:BundleReference runat="server" Path="~/Content/css" /> 
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
<asp:ContentPlaceHolder runat="server" ID="HeadContent" />

</head>
<body>
<form runat="server">
<asp:HiddenField ID="selected_tab" runat="server" />
<asp:ScriptManager runat="server">
<Scripts>
<%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=272931&clcid=0x409 --%>
<%--Framework Scripts--%>

<asp:ScriptReference Name="MsAjaxBundle" />
<asp:ScriptReference Name="jquery"/>
<asp:ScriptReference Name="jquery.ui.combined" />
<asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
<asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
<asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
<asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
<asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
<asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
<asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
<asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
<asp:ScriptReference Name="WebFormsBundle" />
<asp:ScriptReference path="~/Scripts/jquery-1.8.2.js" />
<%--Site Scripts--%>

</Scripts>
</asp:ScriptManager>

<div id="body">

<div class="content-wrapper">
<div class="float-left">
<p class="site-title">
<a runat="server" href="~/">your logo here</a>
</p>
</div>
<div class="float-left">
<ul id="menu">
<li><a runat="server" href="~/">Home</a></li>
<li><a runat="server" href="~/About">About</a></li>
<li><a runat="server" href="~/Contact">Contact</a></li>
</ul>
</div>
</div>

<asp:ContentPlaceHolder runat="server" ID="FeaturedContent" />
<section class="content-wrapper main-content clear-fix">
<asp:ContentPlaceHolder runat="server" ID="MainContent" />
</section>

</div>



<script type="text/javascript">
var selected_tab = 1;




$('#menu > li').click(function () {

selected_tab = $(this).index();
$("form").submit(function () {
$("[id$=selected_tab]").val(selected_tab);
});
});

$(document).ready(function () { alert($("[id$=selected_tab]").val()); });

</script>

</form>

</body>
</html>

you are doing a form submit, which replaces the current page with a new one. no javascript variables will survive this. you can use a hidden field, just be sure the server postback code returns it in the response. 

in your case you using an anchor, not a form post, so the hidden field is not included, because there is no postback. just add it to the link :

<ul id="menu">
<li><a runat="server" href="~/?selected_tab=1">Home</a></li>
<li><a runat="server" href="~/About?selected_tab=2">About</a></li>
<li><a runat="server" href="~/Contact?selected_tab=3">Contact</a></li>
</ul>

just be sure to copy the value to the hidden field server side.

[RESOLVED]DetailsView TemplateField Code reuse

I have a DetailsView with a template field with the following code:

<EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("NSN") %>' MaxLength="50"></asp:TextBox>The maximum length of the NSN is 50.
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("NSN") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("NSN") %>'></asp:Label>
                    </ItemTemplate>

I would like to have the same code in the InsertItemTemplate as in the EditItemTemplate.  I know I could just cut and paste the code from one template to the other, but I’m looking for something easier to maintain.  Is there a way to write the code in one
place and just have both templates reference the same piece of code?  Some sort of function or style or something?

There might be some hack for that. But really using the separate templates is less error prone I think. If it’s a insert problem/update you work on the insertitemtemplate;  if it’s a update problem/update you work on the edititemt template etc. 

That’s fine.  I just didn’t know what was feasible and what wasn’t.  And I can see the logic behind having them seperate.  It seems like they will remain the same, but perhaps they will need to be tweaked seperately.

[RESOLVED]detailsview validation

I need to do a validaton for a textfield in a detailsview. I have used "custom validator" and want to fire the "server_validate" event. but the "server_validate" event does not fire. I have google for sometime and came to know that it is not possible. However
i need to understand why it is not possible??

Any ideas??[8-)]

 

who said to you that server side validation not fires ?

Check http://forums.asp.net/t/1297601.aspx 

http://forums.asp.net/t/1102008.aspx 

Where did you find that’s not possible? This is normal practice, so it should work!

kamii47

 http://forums.asp.net/t/1102008.aspx 

After seeing the following post only i posted for clarity.

I tried my self by adding a detailsview and a customvalidator and "server_valitdate" function for the custom validator. but the point is the "server_validate" function is never hit.. I would like to know why it was  not possible.??

 

Show an example of the detailsview and the server_validate function?

okay here is code

            <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="Id"
                DataSourceID="SqlDataSource1" Height="50px" Width="125px">
                <Fields>
                    <asp:TemplateField HeaderText="Id" InsertVisible="False" SortExpression="Id">
                        <EditItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text=’<%# Eval("Id") %>’></asp:Label>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text=’<%# Bind("Id") %>’></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Name" SortExpression="Name">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text=’<%# Bind("Name") %>’></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
                                EnableClientScript="False" ErrorMessage="*">*</asp:RequiredFieldValidator>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text=’<%# Bind("Name") %>’></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Position" SortExpression="Position">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox2" runat="server" Text=’<%# Bind("Position") %>’></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label3" runat="server" Text=’<%# Bind("Position") %>’></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />
                </Fields>
            </asp:DetailsView>

  <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
             SelectCommand="SELECT * FROM [MovieCategories]"
            UpdateCommand="UPDATE [MovieCategories] SET [Name] = @Name, [Position] = @Position WHERE [Id] = @Id">
            <UpdateParameters>
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Position" Type="Int32" />
                <asp:Parameter Name="Id" Type="Int32" />
            </UpdateParameters>
             </asp:SqlDataSource>

code behind

 protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (DetailsView1.CurrentMode == DetailsViewMode.Edit)
        {
            TextBox tb = (TextBox)DetailsView1.FindControl("TextBox1");
            if (tb.Text.Length > 0)
            {
                if (args.Value.Length < 1)
                {
                    args.IsValid = false;
                }
                else
                {
                    args.IsValid = true;
                }
            }
        }
    }

Any help???

 

Where is the customvallidator that calls the function? [8-|]

And what exactly is it that you want the validator to do?

Yes From mentioned code we can’t see the custom validator with CustomValidator1_ServerValidate function/event .Is any thing missing in your code ?

kamii47

Yes From mentioned code we can’t see the custom validator with CustomValidator1_ServerValidate function/event .Is any thing missing in your code ?

it is there in the post. but i am giving for reference

 protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (DetailsView1.CurrentMode == DetailsViewMode.Edit)
        {
            TextBox tb = (TextBox)DetailsView1.FindControl("TextBox1");
            if (tb.Text.Length > 0)
            {
                if (args.Value.Length < 1)
                {
                    args.IsValid = false;
                }
                else
                {
                    args.IsValid = true;
                }
            }
        }
    }

A, now I understand the problem!

You made a function, but you forgot to put the Custom Validator in the HTML Markup. Just Add:

<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="ErrorMessage" OnServerValidate="CustomValidator1_ServerValidate"  />

Ganesh Jee ,

I can’t see the CustomValidator where CustomValidator1_ServerValidate is binded.

Is there any asp:CustomValidator control with above server validation function is present in your markup ?

 

kamii47

Ganesh Jee ,

I can’t see the CustomValidator where CustomValidator1_ServerValidate is binded.

Is there any asp:CustomValidator control with above server validation function is present in your markup ?

here is the code

<EditItemTemplate>

<asp:TextBox
ID="TextBox1"
runat="server"
Text=’<%# Bind("Name") %>‘></asp:TextBox>&nbsp;

<asp:CustomValidator
ID="CustomValidator1"
runat="server"
ControlToValidate="TextBox1"

ErrorMessage="CustomValidator"
OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator>

</EditItemTemplate>

Sorry, i might have missed out while pasting the code.

 

Are you sure this is not firing?  Do you have a breakpoint on the first line of your event handler?  Maybe the DetailsView1 is in insert mode and your code is working perfectly.

try to set the OldValuesParameterFormatString Property in the SqlDataSource:

  <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
             SelectCommand="SELECT * FROM [MovieCategories]"
             OldValuesParameterFormatString="{0}"
             UpdateCommand="UPDATE [MovieCategories] SET [Name] = @Name, [Position] = @Position WHERE [Id] = @Id">
            <UpdateParameters>
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Position" Type="Int32" />
                <asp:Parameter Name="Id" Type="Int32" />
            </UpdateParameters>
             </asp:SqlDataSource>

 

Hi Ganesh ,

Try to add ValidateEmptyText="True"

Otherwise , it will not fire the event hanlder when the textbox is empty.

 

Samu Zhang – MSFT

Hi Ganesh ,

Try to add ValidateEmptyText="True"

Yes. it is Server side event is fireing nw.

 

We Are Glad that u have finally solved your problem.

Ganesh Jee Please mark the Post that help you in solving your problem as answer.[not your own post [:D]]

I tried this, but i want to use custom validator in insert mode but still not firing

any suggestions? will it fire inserttemplate?

Yerbol

I tried this, but i want to use custom validator in insert mode but still not firing

any suggestions? will it fire inserttemplate?

 

If you” ve a question. please start your own thread?

http://www.mikesdotnetting.com/Article/69

I was having the same issue with the CustomValidator not firing while a DetailsView was in Insert mode. Some of the responses above helped to to figure out more of what is going on.  Here is what I’ve found: the CustomValidator will only fire after all the
other validator types on the form have fired and validate successfully.

To explain what I mean consider this example:

<asp:GridView ID="gvNews" runat="server" Width="100%" DataSourceID="sqlNews" DataKeyNames="newsId" CellPadding="4" AutoGenerateColumns="false">
  <Columns>
    <asp:CommandField ButtonType="Button" SelectText="View/Edit" ShowSelectButton="true" ItemStyle-Width="75px" />
    <asp:TemplateField HeaderText="Date">
      <ItemStyle Width="160px" />
      <ItemTemplate>
        <asp:Literal ID="gvDate" runat="server" Text=’<%# Eval("newsDate", "{0:MMMM dd, yyyy @ hh:mm tt}") %>’ />
      </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Title">
      <ItemTemplate>
        <asp:Literal ID="gvTitle" runat="server" Text=’<%# Eval("Title") %>’ />
      </ItemTemplate>
    </asp:TemplateField>
  </Columns>
</asp:GridView>

<div style="margin-top: 12px;">
  <asp:DetailsView ID="dvNews" runat="server" Width="100%" DataSourceID="sqlNewsDetails" DataKeyNames="newsId" CellPadding="6" AutoGenerateRows="false">
    <FieldHeaderStyle Width="100px" />
    <Fields>
      <asp:CommandField ButtonType="Button" EditText="Edit" UpdateText="Save Changes" CancelText="Cancel" ShowEditButton="true" />
      <asp:TemplateField HeaderText="Title*">
        <ItemTemplate>
          <asp:Literal ID="dvTitle" runat="server" Text=’<%# Eval("title_EN") %>’ />
        </ItemTemplate>
        <EditItemTemplate>
          <asp:TextBox ID="txtTitle" runat="server" Width="350px" MaxLength="75" Text=’<%# Bind("title_EN") %>’ />
          <asp:RequiredFieldValidator ID="rfvTitle" runat="server" ControlToValidate="txtTitle" CssClass="errorMessage" Display="Dynamic">What is the Title?</asp:RequiredFieldValidator>
        </EditItemTemplate>
      </asp:TemplateField>
      <asp:TemplateField HeaderText="Video">
        <ItemTemplate>
          <asp:Literal ID="dvVideo" runat="server" Text=’<%# If(String.IsNullOrEmpty(Eval("videoId").ToString), "", String.Format("({0}) {1}", Eval("streamingProviderName"), Eval("videoId"))) %>’ />
        </ItemTemplate>
        <EditItemTemplate>
          <div>
            <asp:DropDownList ID="ddlVideoProvider" runat="server" Width="355px" DataSourceID="sqlVideoProviders" DataTextField="streamingProviderName" DataValueField="providerId" SelectedValue=’<%# Bind("videoProviderId") %>’ AppendDataBoundItems="true">
              <asp:ListItem Text="Select a Streaming Video Provider from the list…" Value="" />
            </asp:DropDownList>
            <asp:CustomValidator ID="cvVideoProvider" runat="server" ControlToValidate="ddlVideoProvider" OnServerValidate="validateVideoProvider" ValidateEmptyText="true" CssClass="errorMessage" Display="Dynamic">If you select a Video Provider, you must enter
a Video ID.</asp:CustomValidator>
          </div>
          <div>
            <asp:TextBox ID="txtVideoId" runat="server" Width="350px" MaxLength="25" Text=’<%# Bind("videoId") %>’ />
            <asp:CustomValidator ID="cvVideoId" runat="server" ControlToValidate="txtVideoId" OnServerValidate="validateVideoId" ValidateEmptyText="true" CssClass="errorMessage" Display="Dynamic">If you enter a Video Id, you must select a Video Provider.</asp:CustomValidator>
          </div>
        </EditItemTemplate>
      </asp:TemplateField>
    </Fields>
  </asp:DetailsView>
</div>

<asp:SqlDataSource ID="sqlNews" runat="server" ConnectionString="<%$ ConnectionStrings: ConnString %>"

SelectCommand="SELECT newsId, Title_EN AS Title, newsDate FROM cms_News ORDER BY newsDate DESC" SelectCommandType="Text">
</asp:SqlDataSource>

<asp:SqlDataSource ID="sqlNewsDetails" runat="server" ConnectionString="<%$ ConnectionStrings: ConnString %>"

SelectCommand="SELECT newsId, title_EN, videoId, videoProviderId, streamingProviderName FROM cms_News n LEFT JOIN cms_VideoProviders vp ON n.videoProviderId=vp.providerId WHERE newsId=@newsId" SelectCommandType="Text"
UpdateCommand="UPDATE cms_News SET title_EN=@title_EN, videoId=@videoId, videoProviderId=@videoProviderId WHERE newsId=@newsId" UpdateCommandType="Text">
<SelectParameters>
  <asp:ControlParameter Name="newsId" Type="Int32" ControlID="gvNews" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>

<asp:SqlDataSource ID="sqlVideoProviders" runat="server" ConnectionString="<%$ ConnectionStrings: ConnString %>"
SelectCommand="SELECT providerId, streamingProviderName FROM cms_VideoProviders ORDER BY streamingProviderName" SelectCommandType="Text">
</asp:SqlDataSource>

This is a fully functioning demo. All you need to do is create a database with the two tables showing in the SqlDataSource statements. The idea is the GridView shows all of the news items. Each news item can have an embedded video associated with it. In
order to provide flexibility on the embedded videos, the VideoProvider table defines all the available video providers. The CustomValidators make sure that if a Video Provider is selected then a VideoId is entered and visa versa.

Notice how the Title field is marked as a required field and has a RequiredFieldValidator attached to it. If the Title field has an entry in it (and therefore the RequiredFieldValidator is successful) then, and only then will the CustomValidators fire and
make sure the the Video stuff is all there if an entry is made in one or the other field. If the Title field is empty, then only the RequiredFieldValidator will fire and none of the error messages for the DropDownList or the TextBox will fire.

This holds true for Edit mode or Insert mode.

I hope this helps others understand a bit better what is happening and when to expect the CustomValidators to fire.

rweiler

I was having the same issue

And did read my previous answer?

Stumped trying to figure out DetailsView check all checkboxes button conversions

 I’m in the process of trying to figure out a DetailsView coding challenge that I’m completely and utterly stumped on (and Google hasn’t been much help at all).  I have a DetailsView form with 19 checkboxes and a bunch of DataFields around the checkboxes. 
Now the form as/is works with no issues.  However, I need to add a button below the checkboxes that will only check all the checkboxes to save time for form entry.  The challenge I’m facing is not only getting the button to only check all the checkboxes at
once, but getting past this error when load the page:

Cannot convert type ‘System.Web.UI.WebControls.TableCell’ to ‘System.Web.UI.WebControls.CheckBox’ via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion

As much as I’d like to figure out what the final code is supposed to look like, I’d like to learn where I went wrong with the code I posted below but also to learn the logic behind what is needed to make the button check all the checkboxes.

Also, if there some good references (books, links, etc) to help me with these sorts of challenges in the future, that would be greatly appreciated.  Hands on and theory references are what I’m looking for.

 

 

aspx code.

 

(Note some cosmetic code for the details view has been omitted)


<%@ Page Title="Test Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="form2.aspx.cs" Inherits="form2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" Runat="Server">
    <asp:DetailsView ID="DetailsView" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None">
        <AlternatingRowStyle BackColor="White" />
		<insert asp cosmetic gobbledy gook here>
        <Fields>
            <asp:BoundField DataField="Field_1" HeaderText="Ticket Number" SortExpression="Field_1" />
            <asp:BoundField DataField="Field 2" HeaderText="Field 2" SortExpression="Field_2" />
            <asp:BoundField DataField="Field_3" HeaderText="Field 3" SortExpression="Field_3" />
            <asp:BoundField DataField="Field_4" HeaderText="Field 4" SortExpression="Field_4" />
            <asp:BoundField DataField="Field_5" HeaderText="Field 5" SortExpression="Field_5" />
            <asp:BoundField DataField="Field_6" HeaderText="Field 6" SortExpression="Field_6" />
            <asp:BoundField DataField="Field_7" HeaderText="Field 7" SortExpression="Field_7" />
            <asp:BoundField DataField="Field_8" HeaderText="Field 8" SortExpression="Field_8" />
            <asp:BoundField DataField="Field_9" HeaderText="Field 9" SortExpression="Field_9" />
			<asp:BoundField DataField="Field_10" HeaderText="Field 10" SortExpression="Field_10" />
            <asp:CheckBoxField DataField="Check_Box_1" HeaderText="Check Box 1" SortExpression="Check_Box_1" />
            <asp:CheckBoxField DataField="Check_Box_2" HeaderText="Check Box 2" SortExpression="Check_Box_2" />
            <asp:CheckBoxField DataField="Check_Box_3" HeaderText="Check Box 3" SortExpression="Check_Box_3" />
            <asp:CheckBoxField DataField="Check_Box_4" HeaderText="Check Box 4" SortExpression="Check_Box_4" />
            <asp:CheckBoxField DataField="Check_Box_5" HeaderText="Check Box 5" SortExpression="Check_Box_5" />
            <asp:CheckBoxField DataField="Check_Box_6" HeaderText="Check Box 6" SortExpression="Check_Box_6" />
            <asp:CheckBoxField DataField="Check_Box_7" HeaderText="Check Box 7" SortExpression="Check_Box_7" />
            <asp:CheckBoxField DataField="Check_Box_8" HeaderText="Check Box 8" SortExpression="Check_Box_8" />
            <asp:CheckBoxField DataField="Check_Box_9" HeaderText="Check Box 9" SortExpression="Check_Box_9" />
            <asp:CheckBoxField DataField="Check_Box_10" HeaderText="Check Box 10" SortExpression="Check_Box_10" />
            <asp:CheckBoxField DataField="Check_Box_11" HeaderText="Check Box 11" SortExpression="Check_Box_11" />
            <asp:CheckBoxField DataField="Check_Box_12" HeaderText="Check Box 12" SortExpression="Check_Box_12" />
			<asp:CheckBoxField DataField="Check_Box_13" HeaderText="Check Box 13" SortExpression="Check_Box_13" />
			<asp:CheckBoxField DataField="Check_Box_14" HeaderText="Check Box 14" SortExpression="Check_Box_14" />
			<asp:CheckBoxField DataField="Check_Box_15" HeaderText="Check Box 15" SortExpression="Check_Box_15" />
			<asp:CheckBoxField DataField="Check_Box_16" HeaderText="Check Box 16" SortExpression="Check_Box_16" />
			<asp:CheckBoxField DataField="Check_Box_17" HeaderText="Check Box 17" SortExpression="Check_Box_17" />
			<asp:CheckBoxField DataField="Check_Box_18" HeaderText="Check Box 18" SortExpression="Check_Box_18" />
			<asp:CheckBoxField DataField="Check_Box_19" HeaderText="Check Box 19" SortExpression="Check_Box_19" />
			
			
			<asp:ButtonField ButtonType="Button" CommandName="btnSelectAll" Text="Select/Check All Servers"
			
			
			<asp:BoundField DataField="Field_11" HeaderText="Field 11" SortExpression="Field_11" />
            <asp:BoundField DataField="Field_12" HeaderText="Field 12" SortExpression="Field_12" />
            <asp:BoundField DataField="Field_13" HeaderText="Field 13" SortExpression="Field_13" />
			
			<asp:CommandField ButtonType="Button" NewText="CreateRecord" ShowInsertButton="True" />
		</Fields>
		<more asp non essential cosmetic gobbledy gook>
		
			</asp:DetailsView>
			<asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:test_form_connect %>" runat="server" InsertCommand="INSERT INTO [test].[detailsview_test_form] ([Field_1], [Field_2], [Field_3], [Field_4], [Field_5], [Field_6], [Field_7], [Field_8], [Field_9], [Field_10], [Check_Box_1], [Check_Box_2], [Check_Box_3], [Check_Box_4], [Check_Box_5], [Check_Box_6], [Check_Box_7], [Check_Box_8], [Check_Box_9], [Check_Box_10], [Check_Box_11], [Check_Box_12], [Check_Box_13], [Check_Box_14], [Check_Box_15], [Check_Box_16], [Check_Box_17], [Check_Box_18], [Check_Box_19], [Field_11], [Field_12], [Field_13]) VALUES (@Field_1, @Field_2, @Field_3, @Field_4, @Field_5, @Field_6, @Field_7, @Field_8, @Field_9, @Field_10, @Check_Box_1, @Check_Box_2, @Check_Box_3, @Check_Box_4, @Check_Box_5, @Check_Box_6, @Check_Box_7, @Check_Box_8, @Check_Box_9, @Check_Box_10, @Check_Box_11, @Check_Box_12, @Check_Box_13, @Check_Box_14, @Check_Box_15, @Check_Box_16, @Check_Box_17, @Check_Box_18, @Check_Box_19, @Field_11, @Field_12, @Field_13) ">
	
			<InsertParameters>
		<asp:Parameter Name="Field_1" />
		<asp:Parameter Name="Field_2" />
		<asp:Parameter Name="Field_3" />
		<asp:Parameter Name="Field_4" />
		<asp:Parameter Name="Field_5" />
		<asp:Parameter Name="Field_6" />
		<asp:Parameter Name="Field_7" />
		<asp:Parameter Name="Field_8" />
		<asp:Parameter Name="Field_9" />
		<asp:Parameter Name="Field_10" />
		<asp:Parameter Name="Check_Box_1" />
		<asp:Parameter Name="Check_Box_2" />
		<asp:Parameter Name="Check_Box_3" />
		<asp:Parameter Name="Check_Box_4" />
		<asp:Parameter Name="Check_Box_5" />
		<asp:Parameter Name="Check_Box_6" />
		<asp:Parameter Name="Check_Box_7" />
		<asp:Parameter Name="Check_Box_8" />
		<asp:Parameter Name="Check_Box_9" />
		<asp:Parameter Name="Check_Box_10" />
		<asp:Parameter Name="Check_Box_11" />
		<asp:Parameter Name="Check_Box_12" />
		<asp:Parameter Name="Check_Box_13" />
		<asp:Parameter Name="Check_Box_14" />
		<asp:Parameter Name="Check_Box_15" />
		<asp:Parameter Name="Check_Box_16" />
		<asp:Parameter Name="Check_Box_17" />
		<asp:Parameter Name="Check_Box_18" />
		<asp:Parameter Name="Check_Box_19" />
		<asp:Parameter Name="Field_11" />
		<asp:Parameter Name="Field_12" />
		<asp:Parameter Name="Field_13" />
		
				</InsertParameters>
				</asp:SqlDataSource>
			    
         
</asp:Content>

 

 

 

 

 

….and here’s the C# code.

 

 

 

 

 

 

 

using System;
using System.Configuration;
using System.Collections;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class form2 : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{
	
	}
	
	protected void DetailsView1_ItemCommand(Object sender, DetailsViewCommandEventArgs e)
	{
		foreach (Details
			if (e.CommandName == "btnSelectAll")
			{
			DetailsViewRow row = DetailsView1.Rows[9];
            (row.Cells[10] as CheckBox).Checked = true; 
            DetailsViewRow row1 = DetailsView1.Rows[10];
            (row1.Cells[11] as CheckBox).Checked = true;
            DetailsViewRow row2 = DetailsView1.Rows[11];
            (row.Cells[12] as CheckBox).Checked = true;
            DetailsViewRow row3 = DetailsView1.Rows[12];
            (row.Cells[13] as CheckBox).Checked = true;
            DetailsViewRow row4 = DetailsView1.Rows[13];
            (row.Cells[14] as CheckBox).Checked = true;
            DetailsViewRow row5 = DetailsView1.Rows[14];
            (row.Cells[15] as CheckBox).Checked = true;
            DetailsViewRow row6 = DetailsView1.Rows[15];
            (row.Cells[16] as CheckBox).Checked = true;
            DetailsViewRow row7 = DetailsView1.Rows[16];
            (row.Cells[17] as CheckBox).Checked = true;
            DetailsViewRow row8 = DetailsView1.Rows[17];
            (row.Cells[18] as CheckBox).Checked = true;
            DetailsViewRow row9 = DetailsView1.Rows[18];
            (row.Cells[19] as CheckBox).Checked = true;
            DetailsViewRow row10 = DetailsView1.Rows[19];
            (row.Cells[20] as CheckBox).Checked = true;
            DetailsViewRow row11 = DetailsView1.Rows[20];
            (row.Cells[21] as CheckBox).Checked = true;
            DetailsViewRow row12 = DetailsView1.Rows[21];
            (row.Cells[22] as CheckBox).Checked = true;
            DetailsViewRow row13 = DetailsView1.Rows[22];
            (row.Cells[23] as CheckBox).Checked = true;
            DetailsViewRow row14 = DetailsView1.Rows[23];
            (row.Cells[24] as CheckBox).Checked = true;
            DetailsViewRow row15 = DetailsView1.Rows[24];
            (row.Cells[25] as CheckBox).Checked = true;
            DetailsViewRow row16 = DetailsView1.Rows[25];
            (row.Cells[26] as CheckBox).Checked = true;
            DetailsViewRow row17 = DetailsView1.Rows[26];
            (row.Cells[27] as CheckBox).Checked = true;
            DetailsViewRow row18 = DetailsView1.Rows[27];
            (row.Cells[28] as CheckBox).Checked = true;
            DetailsViewRow row19 = DetailsView1.Rows[28];
            (row.Cells[29] as CheckBox).Checked = true;



        }
    } 	
}

 

 

 

 

Hye Technie Joe are you using Template field or bound field?

tharmen

Hye Technie Joe are you using Template field or bound field?

Not with this example.  I’m open to it but this was a suggestion from a different coding board.  After he posted sample code he didn’t reply which tells me that he may not know how to solve this problem himself.  I was under the assumption based on the code
sample provided and the lack of solid references via Google, that this was the only option I had to solve this.

Anybody?  I’m open to other ways of getting this done.

Design View Changes Don't Alter Source Code

 I had this problem several times. I made a change to a control usually a data control like a gridview, detailsview, and right now a listview. When I finish making the changes in design view I notice that the tab does not have the * indicating a change and
when I go to source mode none of my changes have been reflected in the code. Why is this?

This may happen if you try to change anything while your application is running in debug mode. Please check if that’s not the case.

Hope it helps.

[RESOLVED]Show a detailsview in jquery dialog after selecting record in gridview

Hi!

I have web forms page that has 2 controls. A gridview and an associated listview.

When i select the record in gridview the page posts back and i see the details of the gridline in listview which is located below the grid.

Now i want to transfer the listview to a jquery dialog control.

I have tried to find a solid way to do it but i am confused.

Any suggestions?

Should i have to drop listview in a separate page and then call the page from the grid inside a jquery dialog? (how?)

Is there a way to call the listview and show it in a dialog box instead of showing it below the gris?

Thanks

Just put the listview inside of a <div> and use jQuery UI to $().dialog() the <div> when the page loads.

EDIT: It seems to work..now the only thing i need is to detect in jquery page load if it is a postback, because i dont need it in every page loading..

If i do it in every page load i will always get a dialog..or not? i only want the dialog to appear when i select a grid row, and to be able to do the edit,insert operations of the detailsview in the dialogbox…Am i asking too much? :)

This is what i have done. Below is the whole markup of the page that contains the gridview and the detailsview control. What happens is that when i click the select linkbutton in the gridview the dialog opens and imediately closes because i think he is doing
a postback to fill the detailsview….I have added the open function in the onclientclick event of the select…

<div id="divTodo_Details">
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
        DataKeyNames="id" DataSourceID="dsTodo_Details" Height="50px"
        Width="922px" GridLines="None"
    oniteminserting="DetailsView1_ItemInserting"
        onitemupdated="DetailsView1_ItemUpdated" CssClass="ui-state-default">
        <FieldHeaderStyle CssClass="ui-state-active" HorizontalAlign="Right"
            VerticalAlign="Middle" Wrap="False" />
        <Fields>
            <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False"
                ReadOnly="True" SortExpression="id" Visible="False" />
            <asp:BoundField DataField="projectId" HeaderText="projectId"
                SortExpression="projectId" Visible="False" />
            <asp:TemplateField HeaderText="Project  :" SortExpression="projectName">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="dsProject"
                        DataTextField="projectName" DataValueField="projectId"
                        SelectedValue='<%# Bind("projectId") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:DropDownList ID="drpIProject" runat="server" DataSourceID="dsProject"
                        DataTextField="projectName" DataValueField="projectId"
                        SelectedValue='<%# Bind("projectId") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label10" runat="server" Text='<%# Eval("projectName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="subprojectId" HeaderText="subprojectId"
                SortExpression="subprojectId" Visible="False" />
            <asp:TemplateField HeaderText="Sub Project  :" SortExpression="subprojectName">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="dsSubproject"
                        DataTextField="subprojectName" DataValueField="subprojectId"
                        SelectedValue='<%# Bind("subprojectId") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:DropDownList ID="drpISubproject" runat="server"
                        DataSourceID="dsSubproject" DataTextField="subprojectName"
                        DataValueField="subprojectId" SelectedValue='<%# Bind("subprojectId") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("subprojectName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="unitId" HeaderText="unitId" SortExpression="unitId"
                Visible="False" />
            <asp:TemplateField HeaderText="YLA Group  :" SortExpression="unitName">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="dsUnit"
                        DataTextField="unitName" DataValueField="unitId"
                        SelectedValue='<%# Bind("unitId") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:DropDownList ID="drpIUnit" runat="server" DataSourceID="dsUnit"
                        DataTextField="unitName" DataValueField="unitId"
                        SelectedValue='<%# Bind("unitId") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("unitName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="externalId" HeaderText="externalId"
                SortExpression="externalId" Visible="False" />
            <asp:TemplateField HeaderText="External Responsible  :"
                SortExpression="externalName">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="dsExternal"
                        DataTextField="externalName" DataValueField="externalId"
                        SelectedValue='<%# Bind("externalId") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:DropDownList ID="drpIExternal" runat="server" DataSourceID="dsExternal"
                        DataTextField="externalName" DataValueField="externalId"
                        SelectedValue='<%# Bind("externalId") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("externalName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="internalId" HeaderText="internalId"
                SortExpression="internalId" Visible="False" />
            <asp:TemplateField HeaderText="Internal Responsible  :"
                SortExpression="internalName">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList5" runat="server" DataSourceID="dsInternal"
                        DataTextField="internalName" DataValueField="internalID"
                        SelectedValue='<%# Bind("internalId") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:DropDownList ID="drpIInternal" runat="server" DataSourceID="dsInternal"
                        DataTextField="internalName" DataValueField="internalID"
                        SelectedValue='<%# Bind("internalId") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("internalName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="statusId" HeaderText="statusId"
                SortExpression="statusId" Visible="False" />
            <asp:TemplateField HeaderText="Status  :" SortExpression="statusName">
                <ItemTemplate>
                    <asp:Label ID="Label6" runat="server" Text='<%# Bind("statusName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Subject  :" SortExpression="subject">
                <EditItemTemplate>
                    <asp:TextBox ID="txtESubject" runat="server" Text='<%# Bind("subject") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="vdESubject" runat="server"
                        ControlToValidate="txtESubject" CssClass="ui-state-error"
                        ErrorMessage="Subject Required"></asp:RequiredFieldValidator>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="txtISubject" runat="server" Text='<%# Bind("subject") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="vdISubject" runat="server"
                        ControlToValidate="txtISubject" CssClass="ui-state-error"
                        ErrorMessage="Subject Required"></asp:RequiredFieldValidator>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label8" runat="server" Text='<%# Bind("subject") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Description  :" SortExpression="description">
                <EditItemTemplate>
                    <table style="width: 100%;">
                        <tr>
                            <td>
                                <asp:TextBox ID="txtEDescription" runat="server" Height="100px" Rows="30"
                                    Text='<%# Bind("description") %>' TextMode="MultiLine" Width="800px"></asp:TextBox>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="vdEDescription" runat="server"
                                    ControlToValidate="txtEDescription" CssClass="ui-state-error"
                                    ErrorMessage="Required!"></asp:RequiredFieldValidator>
                            </td>
                            <td>
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td>
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td>
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                        </tr>
                    </table>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <table style="width: 100%;">
                        <tr>
                            <td>
                                <asp:TextBox ID="txtIDescription" runat="server" Height="100px" ReadOnly="True"
                                    Rows="30" Text='<%# Bind("description") %>' TextMode="MultiLine"
                                    Width="800px"></asp:TextBox>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="vdIDescription" runat="server"
                                    ControlToValidate="txtIDescription" CssClass="ui-state-error"
                                    ErrorMessage="Required!"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                    </table>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:TextBox ID="TextBox9" runat="server" Height="100px" Rows="30"
                        Text='<%# Bind("description") %>' Width="800px" ReadOnly="True"
                        TextMode="MultiLine"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Link  :" SortExpression="link">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("link") %>'></asp:TextBox>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("link") %>'
                        Width="640px"></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("link") %>'
                        Text='<%# Eval("link") %>'></asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Created on  :" SortExpression="dateOpened">
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox10" runat="server" Text='<%# Bind("dateOpened","{0:d}") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label7" runat="server" Text='<%# Bind("dateOpened","{0:d}") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Closed On  :" SortExpression="dateclosed">
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox11" runat="server" Text='<%# Bind("dateclosed","{0:d}") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label9" runat="server" Text='<%# Bind("dateclosed","{0:d}") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Final Comments  :"
                SortExpression="commentsClosed">
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("commentsClosed") %>'></asp:TextBox>
                </InsertItemTemplate>
                <ItemTemplate>
                    <asp:TextBox ID="TextBox12" runat="server" Height="100px" ReadOnly="True"
                        Rows="30" Text='<%# Eval("commentsClosed") %>' TextMode="MultiLine"
                        Width="800px"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
        </Fields>
    </asp:DetailsView>
    
        
    <br />
    <br />
    </div>

IIRC, the grid has a selected row index property (or something like that?) so maybe you can consult that server-side to then choose if you need to dynamically emit the javascript to trigger the dialog.

Propably i confused you with my above post…

Showing the dialog in page load of jquery works. and i get my dialog.also if i press the edit or insert butoons in the dialog i get the dialog as i want in the next postback.

My problem with this now is that i dont want to get the dialog in every postback, or to say it better, i want to get the dialog ONLY :

-if the postback comes from the gridview

-if the postback comes from the listview

i need this because i have other controls in the page from which i dont want to get the dialog when they do their postback…

earthdog

My problem with this now is that i dont want to get the dialog in every postback, or to say it better, i want to get the dialog ONLY :

-if the postback comes from the gridview

-if the postback comes from the listview

So keep a flag in the page that you set if those conditions are true and only render the dialog code if your flag has been set. *shrug*

sorry for being a noob in asp.net :)

So what you say is  to write some kind of code in page_load of my c# to inject in the DOM a value that i can check with jquery?

If yes how?

i think of:

-create a label that is hidden and assign a true of false value.

but how to check in my c# page load which control caused the postback?

So you can keep a flag in the page:

public class MyPage : Page

{

protected bool ShowDialog = false;

}

and in the .aspx:

<script>

var showDialog = <%= ShowDialog ? "true" : "false" %>;

</script>

and then for the events on the controls that you know are from your grid/listview you can set ShowDialog = true; You’ll have to figure out which events those controls raise.

got it and will try it. thanks a lot!

The next challenge is to make the operations of listview to work in the dialog.Now what it does is:

-I click on the proper control and the dialog opens with a listview to show the details of the gridline.

-the listview has a button for insert and update operation.

-When i click the update the page postback and in the new dialog i get the listview in edit mode. up to here is ok.

-when i click the update button something is going wrong because he thinks that the fields are empty and the validation kicks in…

Any idea on this?

Also with the variable i have to make the var false in all the clicks from the control that i dont want…its not a problem for me though…

Hi,

If you want to detect, in page_load, which control caused the postback(in your case gridview and listview) you can follow this post-

http://ryanfarley.com/blog/archive/2005/03/11/1886.aspx

Yeap i have stumbled upon this code…

I tried something on my own:

I am giving to the controls i want to show the dialog a class. those that i dont want to create the dialog on postback another class. then i handle the action like this:

if ($("#cphMain_HiddenField1").val() == "dlg") {
    $("#divTodo_Details").dialog({ show: 'fade', hide: 'fade', autoOpen: true, modal: true, title: "Details", width: 1024 });
}
//
$(".showdetails").click(function () {
    $("#cphMain_HiddenField1").val("dlg");
});
//
$(".NOshowdetails").click(function () {
    $("#cphMain_HiddenField1").val("");
});

listview cannot update/delete when inside jquery dialog

Hi!

I have a form with one gridview as master linked to a listview in the same page. Listview shows one record. this happens when i select a row in the grid.

I have successfully managed to get my listview to appear inside a jquery dialog. the problem is that i cant do the edits and insert when inside the dialog box. What happens is that after i press update , after the postback the dialog box has a blank form.

After researching i have found that the problem MAYBE is that the dialog option creates a new div inside my div (by examing the resulting page). This breaks the association of the child elements of the listview and they appear blank….

Any idea on how to fix it?

Hi,

You must be having the listview inside some div which you are showing as dialog. Within that div you add the list view inside update panel, then you need not to worry about hiding and showing of listview dialog on any event of the listview.

Tried it but no change..

My beggining code for detailsview:

<div id="divTodo_Details">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
        DataKeyNames="id" DataSourceID="dsTodo_Details" Height="50px"
        Width="922px" GridLines="None"
    oniteminserting="DetailsView1_ItemInserting"

My ending code:

    </Fields>
    </asp:DetailsView>
    
        
    <br />
    <br />
    </ContentTemplate>
    </asp:UpdatePanel>
    </div>

I click the edit and listview goes to edit mode. When i press cancel the required validation kicks in because all fields are blank..After that if i close the dialog and opened it in other gridview column i go directly in edit mode…..

Strange?

My Javascript code:

$("#divTodo_Details").dialog({ show: 'fade', hide: 'fade', autoOpen: false, modal: true, title: "Details", width: 1024 });
    //
    if ($("#cphMain_HiddenField1").val() == "dlg") {
        $("#divTodo_Details").dialog('open');
    }
    //
    $(".showdetails").click(function () {
        $("#cphMain_HiddenField1").val("dlg");
    });
    //
    $(".NOshowdetails").click(function () {
        $("#cphMain_HiddenField1").val("");
    });

Hi,

How you are doing the loading of the listview on click of the gridview row?

Nothing fancy. I just have the listview connected to the gridview via the SelectCommand of the sqldatasource of the listview.

The current version of the page automatically shows the relevant record of the list view when i press the select button on the gridview…

Ok,

Put your detail view in a updatepanel as you have stated earlier. And also put the gridview in a separeate updatepanel. And associate triger on detatail view updatepanel and assiciate it with the select command of the gridview.

You can use style="display:none" and then, using jquery make it show or hide. 

sorry for my noobness.

Can you please give more details about the linking ….? I cant figure out how to link them …

Ok i understood that i had to create an asyn trigger from detailsview to -> gridview .selecteditemchange

but then what? do i have to write code somewhere?

I mean do i keep the selectcommand linking to gridview in the detailsview datasource? or not? do i have to write code on the selecteditemchage event to change the select command of the datasource?