2011-04-23 139 views
0

這是我設計的我怎麼能有一個GridView或詳細視圖在一個彈出式

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
    <ContentTemplate> 
     <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Font-Names="Arial" 
      Font-Size="11pt" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" 
      CellPadding="4" OnRowCommand="GridView1_RowCommand"> 
      <Columns> 
       <asp:TemplateField> 
        <HeaderTemplate> 
         <asp:CheckBox ID="CheckAll" onclick="return check_uncheck (this);" runat="server" /> 
        </HeaderTemplate> 
        <ItemTemplate> 
         <asp:Label ID="ID" Visible="false" Text='<%# DataBinder.Eval (Container.DataItem, "Id") %>' 
          runat="server" /> 
         <asp:CheckBox ID="deleteRec" onclick="return check_uncheck (this);" runat="server" /> 
        </ItemTemplate> 
       </asp:TemplateField> 
       <asp:TemplateField HeaderText="Id" 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="FileName" SortExpression="FileName"> 
        <EditItemTemplate> 
         <asp:Label ID="LblFileName" runat="server" Text='<%# Eval("FileName") %>'></asp:Label> 
        </EditItemTemplate> 
        <ItemTemplate> 
         <asp:Label ID="LblFileName1" runat="server" Text='<%# Bind("FileName") %>'></asp:Label> 
         <asp:ImageButton ID="img" runat="Server" CommandName="Image" ImageUrl="~/Images/pen.png" /> 
        </ItemTemplate> 
       </asp:TemplateField> 
      </Columns> 
      <AlternatingRowStyle BackColor="White" /> 
      <RowStyle BackColor="#F7F7DE" /> 
      <FooterStyle BackColor="#CCCC99" /> 
      <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" /> 
      <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" /> 
      <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" /> 
     </asp:GridView> 
     <asp:Panel ID="pnlAddEdit" runat="server" CssClass="modalPopup" Style="display: none" 
      Width="1000px"> 
      <asp:Label Font-Bold="true" ID="Label4" runat="server" Text="File Data"></asp:Label> 
      <br /> 
      <table align="center" width="1000px"> 
       <tr> 
        <td> 
         <asp:Label ID="Label1" runat="server" Text="RecordTypeCode"></asp:Label> 
        </td> 
        <td> 
         <asp:Label ID="lblRec" runat="server" Text="Content"></asp:Label> 
        </td> 
       </tr> 
       <tr> 
        <td> 
         <asp:Label ID="lblFileHeader" runat="server" Text="FileHeader"></asp:Label> 
        </td> 
        <td> 
         <asp:Label ID="txtCustomerID" Width="500px" MaxLength="5" runat="server"></asp:Label> 
        </td> 
       </tr> 
       <tr> 
        <td> 
         <asp:Label ID="lblBatchHeader" runat="server" Text="BatchHeader"></asp:Label> 
        </td> 
        <td> 
         <asp:Label ID="txtBatch" runat="server"></asp:Label> 
        </td> 
       </tr> 
       <tr> 
        <td> 
         <asp:Label ID="Label2" runat="server" Text="EntryDetail"></asp:Label> 
        </td> 
        <td> 
         <asp:Label ID="txtEntry" runat="server"></asp:Label> 
        </td> 
       </tr> 
       <tr> 
        <td> 
         <asp:Button ID="btnSave" runat="server" Text="Save" /> 
        </td> 
        <td> 
         <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClientClick="return Hidepopup()" /> 
        </td> 
       </tr> 
      </table> 
     </asp:Panel> 
     <asp:LinkButton ID="lnkFake" runat="server"></asp:LinkButton> 
     <cc1:ModalPopupExtender ID="popup" runat="server" DropShadow="false" PopupControlID="pnlAddEdit" 
      TargetControlID="lnkFake" BackgroundCssClass="modalBackground"> 
     </cc1:ModalPopupExtender> 
    </ContentTemplate> 
    <Triggers> 
     <asp:AsyncPostBackTrigger ControlID="GridView1" /> 
     <asp:AsyncPostBackTrigger ControlID="btnSave" /> 
    </Triggers> 
</asp:UpdatePanel> 

我已經採取了面板內的一些文本框時,彈出打開,但不是我需要一個GridView控件在那裏,因爲我有顯示大文件

這是我的數據的內容

101 111100022 5104885671104200936A094101CapitalOne       MudiamInc   
5220MudiamInc       A510488567CCDITServices000000110422 1111100020000001 
622968765348545646565  00004000001007   rajeshk     1111100020000001 
62297877654775676546546  00002888891007   rajeshk     1111100020000002 
82200000020194754188000000000000000000688889A510488567       111100020000001 
5220MudiamInc       A510488567CCDITServices000000110422 1111100020000002 
62212345678034354465677  00000864451005   swethau     1111100020000003 
62212345678087664534543  00000559841011   swathiK     1111100020000004 
62212345678097867546435  00000579351012   lavanyaK    1111100020000005 
6221234567806754654435435 00000846761013   AnithaN     1111100020000006 
82200000040049382712000000000000000000285040A510488567       111100020000002 
9000002000001000000060244136900000000000000000071739300          

此我必須在一個次序順序顯示爲

RecordTyecode   Content 

    FileHeader   Starting line to be here 
    BatchHeader  Line that come's with 5(First come line) 
    EntryDetail  Number of 6 line has to be added on by one 
    BatchControl  line that starts with 8 has to be here 

再次,如果我有符合5開始8有要追加像上述順序後

任何能給我一個想法,添加此動態有點棘手,瞭解詢問任何信息需要

這是在做winforms準確,我需要在網絡太

enter image description here

+0

後'我怎麼能有一個GridView或細節在popup'查看可以使用[jQuery的的fancybox( http://fancybox.net/)然後使用iFrame來加載你的頁面。 – 2011-04-23 09:38:55

回答

0

只是以簡單的方式,我得到這個答案

聲明哈希表

static Hashtable rectype = new Hashtable(); 

在頁面加載我添加以下

if (rectype != null) 
{ 
    rectype.Add("1", "File Header"); 
    rectype.Add("5", "Batch Header"); 
    rectype.Add("6", "Entry Detail"); 
    rectype.Add("7", "Addenda Record"); 
    rectype.Add("8", "Batch Control"); 
    rectype.Add("9", "File Control"); 
} 

這是我的代碼當用戶點擊圖片按鈕

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 
{ 
    int id = 0; 
    string strLine = string.Empty; 
    string[] lines = null; 
    if (e.CommandName == "Image") 
    { 
     GridViewRow row = (GridViewRow)((Control)e.CommandSource).Parent.Parent; 
     Label l = (Label)GridView1.Rows[row.RowIndex].Cells[1].FindControl("Label1"); 
     id = Convert.ToInt16(l.Text); 

     string selectSQL = "Select File_Data from tblachmaster WHERE Id IN (" + id + ")"; 

     MySqlCommand cmd1 = new MySqlCommand(selectSQL); 
     cmd1.Parameters.Add("@_id", SqlDbType.Int).Value = id; 
     DataTable dt1 = GetData1(cmd1); 
     if (dt1 != null) 
     { 
      for (int i = 0; i < dt1.Rows.Count; i++) 
      { 
       Byte[] bytes = (Byte[])dt1.Rows[i]["File_Data"]; 
       string text = Encoding.UTF8.GetString(bytes); 
       lines = Regex.Split(text, "\r\n"); 
       strLine = convertArrayToString(lines); 
      } 
     } 
     DataTable table = new DataTable(); 

     table.Columns.Add("RecordTypeCode", typeof(string)); 
     table.Columns.Add("Content", typeof(string)); 
     foreach (string strcontent in lines) 
     { 
      if (strcontent != string.Empty) 
       table.Rows.Add(rectype[(strcontent.Substring(0, 1))], strcontent); 


     } 
     dynamicGridView.DataSource = table; 
     dynamicGridView.DataBind(); 
     popup.Show(); 

    } 
} 

這很適合我,這裏是我的輸出點擊圖像按鈕

enter image description here

0

您可以使用Ajax的流行ü與此類似P控制 - http://www.ezzylearning.com/tutorial.aspx?tid=2861497

+0

但我想在彈出的gridview中添加動態的行和列 – Dotnet 2011-04-23 09:53:30

+0

@Dorababu - 是不是在運行時的問題,你會傳遞列和數據添加到網格視圖的權利? – TechGiant 2011-04-23 10:03:34

+0

技術:但我想添加的內容完全按照張貼的圖像,這就是我想的 – Dotnet 2011-04-23 10:06:03

相關問題