Hello! I have a GridView with data bound fields from a mysql database. It contains two columns IdTask(primary key),
TaskName and one button which opens a jQuery dialog.
I need to fill this dialog based on the on the ID of the task from the row i clicked the button.
And i have a user control with another Gridview which contains said data that i need to display in the dialog.
This is what i have so far:
The aspx Page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register TagPrefix="ucFiles" TagName="Files" Src="~/UserControlFiles.ascx"
the script:
<script>
$(document).ready(function () {
$(".btnFiles").click(function () {
$("#divModalFiles").dialog({
dialogClass: "no-close",
modal: true,
title: "Files",
width: 450,
height: 440,
buttons: {
Close: function () {
$(this).dialog('close');
}
},
open: function (type, data) {
$(this).parent().appendTo("form");
}
});
return false;
});
});
</script>
<form id="form1" runat="server" style="padding: 10px; width: 550px">
<asp:GridView DataKeyNames="IdTask" ID="gvTask" runat="server"
AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="IdTask" HeaderText="ID" />
<asp:BoundField DataField="Name" HeaderText="Task" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="btnFile" CssClass="btnFiles" runat="server" ImageUrl="img/files.png.png"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<div id="divModalFiles" style="display:none">
<ucFiles:Files runat="server"/>
</div>
</form>
</body>
The ascx userControl:
<div id="file">
<asp:Literal ID="litMesaj" runat="server" Visible="false"></asp:Literal>
<asp:FileUpload ID="fUpload" runat="server" />
<br />
<br />
<asp:Label ID="lblDescFile" runat="server" Text="Description"></asp:Label>
<asp:TextBox ID="txtDescFile" runat="server" ></asp:TextBox>
<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" />
<br />
<br />
<asp:GridView ID="gvFiles" DataKeyNames="IdFiles" runat="server" AutoGenerateColumns="false" EmptyDataText="No files uploaded">
<Columns>
<asp:BoundField DataField="IdFiles" HeaderText="ID" />
<asp:BoundField DataField="IdTask" HeaderText="IdTask" />
<asp:BoundField DataField="Name" HeaderText="File Name" />
<asp:BoundField DataField="Description" HeaderText="Description" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkDownload" runat="server" Text="Download File" OnClick="lnkDownload_Click" CommandArgument='<%# Eval("Url") %>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton runat="server" ID="btnDelFile" ImageUrl="~/delete.png.png" OnClientClick="return confirm('Sure?');" OnClick="btnDelFile_Click"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
The ascx.cs userControl:
private void loadFiles()
{
string sqlFiles = "select * from files where IdTask=" + ?? ;
MySqlCommand cmd = new MySqlCommand(sqlFiles, conn);
MySqlDataAdapter adp = new MySqlDataAdapter(cmd);
DataTable dtFiles = new DataTable();
adp.Fill(dtFiles);
gvFiles.DataSource = dtFiles;
gvFiles.DataBind();
}
Can you help me ? without that ID i can't use the download or the upload files functions either. It currently shows only the form with the files upload and the upload button
If i didn't made myself clear(English is not my first language) with what i need please feel free to ask any questions and i will explain :)
EDIT:
I also want to add that in the database i have 2 tables:
1. IdTask, Task
2. IdFile, IdTask, FileName, etc..
so each task has a coresponding file
What I have tried:
watching all sorts of tutorials and still don't have a solution