|
Creating a class and accessing the base class to get the data out is anyway going to waste your memory. Actually you will be wasting double the memory by doing it this [Memory for your original class and memory for the new class with the filtered data].
Its is better to either put a different class that pulls out only the data required for the grid or to leave your system as-is.
Just my 2 cents. HTH!
|
|
|
|
|
The academic way would certainly be to bind a collection of objects which
only contain the absolute necessary properties. (Keep the view as stupid as possible)
This way, the view cannot mess with data he is not ment to have..
But to be honest, if i dont have huge business entities - maybe even with some crucial
methods inside (uh uh), i use them directly within the view. It always depends
on the situation i guess.
But thats just my opinion.
|
|
|
|
|
Hi,
Anyone please share sample codes for MVC architecture using ASP.NET.
Guhananth.S
|
|
|
|
|
Everything you need is here: read everything.
ASP.NET MVC[^]
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
Hello ,
I work on an intranet site management school, I used the roles for each service (inscription, statistics ,.....) but I blocked on teachers :the responsable for each module has a password and login and I have an aspx file for each module (20 modules). what I want to do and I can not do it: If a teacher connects with his login and password it will be redirected to this module page ? I can not code this code.
Thank you for helping me.
|
|
|
|
|
|
|
dittu7 wrote: If CheckBox1.Checked = True Then
Session("value") = "chkT"
Where in the page is this code written? On which event. Is this code running eveytime you click on checkbox? used Debugger?
Further, what do you mean by 'without closing application when i check..."? You are on two different pages, right? Can you clear your work flow stepwise maybe.
|
|
|
|
|
R u writing this code on Page_Load() event.
if yes, do the code under (! IsPostBack()) function.
regards
Rating always..... WELCOME
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
Hi All,
I created a link button dynamically. using following code
LinkButton lbt = new LinkButton();
lbt.Text = objDt.Rows[j]["sub_grd"].ToString();
lbt.Click += new EventHandler(ctrl_Click); // not working
//then i used
lbt.Attributes.Add("OnClick", "ctrl_Click();"); // not working
Please Help me...
Note : i tried a lot using google help befor posting this thread.
|
|
|
|
|
Did you re-bind the events at postback? You would need to.
|
|
|
|
|
I donk know how to rebind the event please tell me ..
|
|
|
|
|
Let the same code run on each postback! You must be skipping the formation of the button and event assignment on consecutive postbacks.
|
|
|
|
|
On Pageload event repeat the above code
|
|
|
|
|
write this code in
protected void Page_PreInit(object sender, EventArgs e)
{
LinkButton lbt = new LinkButton();
lbt.Text = objDt.Rows[j]["sub_grd"].ToString();
lbt.Click += new EventHandler(ctrl_Click); // not working
//then i used
lbt.Attributes.Add("OnClick", "ctrl_Click();"); // not
}
private void ctrl_Click(object sender, EventArgs e)
{
}
dont write in
protected void Page_Load(object sender, EventArgs e)
{
}
|
|
|
|
|
Hi Visnu,
Thanks for helping me. It does not change the behaviour of link button.
Page_PreInit(object sender, EventArgs e) calls the functions to creats the button programatically but when i click the link button then the dynamic table gets disapeared.
for the solution of problem i wrote the code in the Page_load event and got the results.
But my question, Is it good thing to call same function again and again and get data from database to create table dynamic for same page?
|
|
|
|
|
Check this, it will help you.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="dynamicButton.aspx.cs" Inherits="dynamicButton" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</div>
</form>
<script >
function jsEvent() {
alert("hai");
}
</script>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class dynamicButton : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button button = new Button();
button.ID = "Button1";
button.Text = "DynaicButton";
button.Attributes.Add("onclick", "return jsEvent();");
button.Click += new EventHandler(button_Click);
PlaceHolder1.Controls.Add(button);
}
protected void button_Click(object sender, EventArgs e)
{
Response.Write("Server Event: From Dynamic Button");
}
}
Raju.M
|
|
|
|
|
thanks for Helping me.
i pasted the code in Page load and it is working fine. but page load call this code on each event call. So is it good things to call and fatch record from database for creating table/grid? again and again for same page?
|
|
|
|
|
for Dynamically created controls its good.its for avoid disappearing control in PlaceHolder after postback.
Raju.M
|
|
|
|
|
Hello everyone, I am creating a page with various languages using ASP_Local_resources files, and it works correctly the user is able of choosing the language, but my problem is that in the language change it needs refresh all the screen not only located controls, and the page contains some graphics which make the language change a not very nice repainting, so I am thinking about Ajax in order to change only the afected controls, but I don´t know how to mixture the resources utilization and Ajax, could anybody give me a solution or any link in relation with.
Best Regards
|
|
|
|
|
I'm trying to load multiple images into a GridView from a SQL database based on a UserId. I was only able to get single images to load into a Image box.
On my page "ChangeProfile.aspx" I have:
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
On the code-behind page (in the Page_Load event) I have:
If Not Page.IsPostBack Then
Dim currentUser As MembershipUser = Membership.GetUser
Dim currentUserID As Guid
If Request.QueryString("Id") Is Nothing Then
currentUserID = CType(currentUser.ProviderUserKey, Guid)
Else
currentUserID = New Guid(Request.QueryString("Id"))
End If
Dim connectionString As String = ConfigurationManager.ConnectionStrings("SecurityTutorialsConnectionString").ConnectionString
'Dim insertSql As String = "UPDATE UserProfiles SET MainImage=@Content WHERE UserID=@UserId"
Dim stream As New MemoryStream
Using myConnection As New SqlConnection
myConnection.ConnectionString = connectionString
Dim myCommand As New SqlCommand("SELECT UploadedImage FROM Images WHERE UserId=@UserId", myConnection)
myCommand.Parameters.AddWithValue("@UserId", currentUserID)
Dim ds As New DataSet
Dim Adapter As New SqlDataAdapter(myCommand)
Adapter.Fill(ds)
GridView1.DataSource = ds
GridView1.DataBind()
End Using
End Sub
The table is it trying to pull from ("Images") has the following fields:
ImageId (Guid)
UserId (Guid)
UploadedImage (Image)
ImageDescription (nvarchar(MAX))
The error occurs at the GridView1.DataBind() with the following message:
"The data source for GridView with id 'GridView1' did not have any properties or attributes from which to generate columns. Ensure that your data source has content."
When I look at the table data there are two rows for the supplied UserId (hence two images). I've been working on this for 3 hours straight and cannot figure it out. Any help would be greatly appreciated.
|
|
|
|
|
You need to have more than just this
<asp:GridView ID="GridView1" runat="server"></asp:GridView>
Where is the rest of it? Where are the columns?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Sorry...copied it before I had finished it:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns ="false">
<Columns>
<asp:ImageField ></asp:ImageField>
</Columns>
</asp:GridView>
I just can't figure out how to format the ImageField to display the images bound to the datagrid.
|
|
|
|
|
|
That is exactly what I needed. Thanks everyone!
|
|
|
|