PDA

View Full Version : درج در گریدویو با dropdownlist



mohandesee
شنبه 07 بهمن 1391, 17:18 عصر
مشکلم اینه که بعد از درج بهم پیغام enablepostback رو میده گه بذارم.اما بعد از گذاشتن مشکلم حل نشد.
<%@ Page Title="" Language="C#" MasterPageFile="~/MPage.master" AutoEventWireup="true" CodeFile="MSettingUser.aspx.cs" Inherits="MSettingUser" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<p class="padd-2">
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
</asp:SiteMapPath>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
<h2>
<ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"/>
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/edit_p.jpg" />
&nbsp; </h2></p>
<table align="center" cellpadding="0" cellspacing="0" style="width: 200px;text-align:right;">
<tr>
<td>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False"
DataKeyNames="ID"
DataSourceID="SqlDataSource1"
OnRowDeleted="GridView1_RowDeleted"
OnRowUpdated="GridView1_RowUpdated"
ShowFooter="True"
OnRowCommand="GridView1_RowCommand"
ForeColor="#333333"
Width="50px" AllowPaging="True" AllowSorting="True" CellPadding="4">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ShowDeleteButton="True" DeleteText="حذف"
ShowEditButton="True" EditText="ویرایش" CancelText="لغو"
InsertText="اضافه" NewText="جدید" SelectText="انتخاب" UpdateText="بروزرسانی"/>
<asp:TemplateField HeaderText="ردیف" SortExpression="ID" FooterStyle-Width="25px">
<ItemTemplate>
<asp:Label ID="lblID" runat="server"
Text='<%#Eval("ID") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:ImageButton ID="btnInsert" runat="server" CommandName="Add" ImageUrl="~/images/reg.gif" />
</FooterTemplate>

<FooterStyle Width="25px"></FooterStyle>
</asp:TemplateField>

<asp:TemplateField HeaderText="نام کاربری"
SortExpression="uname" FooterStyle-Width="25px">
<ItemTemplate>
<asp:Label ID="uname" runat="server"
Text='<%#Eval("uname") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtuname" runat="server"
Text='<%#Bind("uname") %>'>
</asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtuname" runat="server">
</asp:TextBox>
</FooterTemplate>

<FooterStyle Width="25px"></FooterStyle>
</asp:TemplateField>
<%-- *********************************--%>

<asp:TemplateField HeaderText="کلمه عبور"
SortExpression="pass">
<ItemTemplate>
<asp:Label ID="pass" runat="server"
Text='<%#Eval("pass") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtpass" runat="server"
Text='<%#Bind("pass") %>'>
</asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtpass" runat="server">
</asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<%--*****************************************--%>
<asp:TemplateField HeaderText="نوع گروه"
SortExpression="group_id">
<ItemTemplate>
<asp:Label ID="lblLocation" runat="server"
Text='<%#Eval("GROUPNAME") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlCountry" runat="server" ></asp:DropDownList>
<ajax:CascadingDropDown ID="CountryCascading" runat="server" Category="Country" TargetControlID="ddlCountry" LoadingText="انتخاب نوع گروه" PromptText="گروه را انتخاب کنید" ServiceMethod="BindCountrydropdown" ServicePath="DropdownWebService.asmx">
</ajax:CascadingDropDown>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddlCountry" runat="server"></asp:DropDownList>
<ajax:CascadingDropDown ID="CountryCascading" runat="server" Category="Country" TargetControlID="ddlCountry" LoadingText="انتخاب نوع گروه" PromptText="گروه را انتخاب کنید" ServiceMethod="BindCountrydropdown" ServicePath="DropdownWebService.asmx">
</ajax:CascadingDropDown>
</FooterTemplate>
</asp:TemplateField>
<%-- *********************************--%>
<asp:TemplateField HeaderText="نام واقعی"
SortExpression="rname">
<ItemTemplate>
<asp:Label ID="rname" runat="server"
Text='<%#Eval("rname") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtrname" runat="server"
Text='<%#Bind("rname") %>'>
</asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtrname" runat="server">
</asp:TextBox>
</FooterTemplate>
</asp:TemplateField>

</Columns>
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F8FAFA" />
<SortedAscendingHeaderStyle BackColor="#246B61" />
<SortedDescendingCellStyle BackColor="#D4DFE1" />
<SortedDescendingHeaderStyle BackColor="#15524A" />
</asp:GridView>
</td>
</tr>
</table>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
DeleteCommand="DELETE FROM [tbl_login] WHERE [id] = @original_id AND (([uname] = @original_uname) OR ([uname] IS NULL AND @original_uname IS NULL)) AND (([pass] = @original_pass) OR ([pass] IS NULL AND @original_pass IS NULL)) AND (([group_id] = @original_group_id) OR ([group_id] IS NULL AND @original_group_id IS NULL)) AND (([rname] = @original_rname) OR ([rname] IS NULL AND @original_rname IS NULL))"
InsertCommand="INSERT INTO [tbl_login] ([uname], [pass], [group_id], [rname]) VALUES (@uname, @pass, @group_id, @rname)"
SelectCommand=" select tbl_login.*,tbl_group.id as group_id_id , tbl_group.group_name as GROUPNAME from tbl_group INNER JOIN tbl_login ON tbl_group.id = tbl_login.group_id ORDER BY [id]"

UpdateCommand="UPDATE [tbl_login] SET [uname] = @uname, [pass] = @pass, [group_id] = @group_id, [rname] = @rname WHERE [id] = @original_id AND (([uname] = @original_uname) OR ([uname] IS NULL AND @original_uname IS NULL)) AND (([pass] = @original_pass) OR ([pass] IS NULL AND @original_pass IS NULL)) AND (([group_id] = @original_group_id) OR ([group_id] IS NULL AND @original_group_id IS NULL)) AND (([rname] = @original_rname) OR ([rname] IS NULL AND @original_rname IS NULL))"
OnInserted="SqlDataSource1_Inserted"
OldValuesParameterFormatString="original_{0}"
ConflictDetection="CompareAllValues">

<DeleteParameters>
<asp:Parameter Name="original_id" Type="Int32" />
<asp:Parameter Name="original_uname" Type="String" />
<asp:Parameter Name="original_pass" Type="String" />
<asp:Parameter Name="original_group_id" Type="Int32" />
<asp:Parameter Name="original_rname" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="uname" Type="String" />
<asp:Parameter Name="pass" Type="String" />
<asp:Parameter Name="group_id" Type="Int32" />
<asp:Parameter Name="rname" Type="String" />
<asp:Parameter Name="original_id" Type="Int32" />
<asp:Parameter Name="original_uname" Type="String" />
<asp:Parameter Name="original_pass" Type="String" />
<asp:Parameter Name="original_group_id" Type="Int32" />
<asp:Parameter Name="original_rname" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="uname" Type="String" />
<asp:Parameter Name="pass" Type="String" />
<asp:Parameter Name="group_id" Type="Int32" />
<asp:Parameter Name="rname" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:Label ID="lblMessage" runat="server"
Font-Bold="True" ForeColor="#003333"></asp:Label>
</asp:Content>