|
|
I have a Grid View. Here I have a column "Active". I attached this GridView to objectDataSource. In database this field has true or false value.(1 or 0). But in Grid View I want to show that if this field has value 1 in database the value for this column should show "Yes" but if the value of this field is 0 in data base the The GridView should show "No".
How can I do that.
seema
|
|
|
|
|
The most obvious way would be to write your data layer to return what you want to show. Otherwise, you need to write a custom column definition which takes the input and shows the text you want.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
How can I create the Custom Column and display the text that if it is 1 then show "Yes" or if it is 0 show "No"
seema
|
|
|
|
|
Which bit are you stuck with ? Naturally, you need to define the columns yourself and turn off the auto creation of columns based on table column names. Then, you define a column which checks if the value is true or false, and emits the right string.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I am using Visual Studio 2002 for learning. I am interested to learn Web forms in Dot Net. I have written objects using Vb.Net in Asp.Net projects. I am facing problem when the objects do not retain value assigned when post back occurs and accross methods written in the code behind page for asp.net page. My friends told me to put object in viewstate or session state. That worked. However, I am not happy. I have observed no such method is used for built objects of Dot Net Class library eg. datagrids, labels, text boxes, drop downs etc. What method they are using to conserve values during post backs I do not know. I know an efficient way of handling objects and values throughout post backs and efficient way of passing objects to another aspx page from within an aspx page during run time.
Kindly help me with sample code and little guidelines.
Thanks,
satishitagi@yahoo.com
satishitagi@yahoo.com
|
|
|
|
|
ASP.NET server controls do use the viewstate to persist their values. Try setting EnableViewState="false" at either page level or object level and you'll see....
Fred
|
|
|
|
|
itagi wrote: passing objects to another aspx page from within an aspx page during run time.
In 2002 the only way to do that is the URL or the session.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have a simple DB with fields ID and Address. Without the Page_Load script, the UpdateButton_Click code works just fine. After adding the Page_Load script (which works just fine), the UpdateButton_Click stops working with no error message; it just saves the old Address value. Why is this happening? I would like to keep my hair and my client :}
Here's the Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim ID As Integer = 2
Dim aTable As New ATSCZDSTableAdapters.ATCSZTableAdapter
Dim aRecords As ATSCZDS.ATCSZDataTable
Dim aRecord As ATSCZDS.ATCSZRow
aRecords = aTable.GetData(ID)
For Each aRecord In aRecords
Try
IDTextBox.Text = aRecord.ID
AddressTextBox.Text = aRecord.Address
Catch ex As Exception
Label2.Text = ex.ToString()
End Try
Next
End Sub
Protected Sub UpdateButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles UpdateButton.Click
Label2.Text = "The record was updated successfully!"
Try
SqlDataSource1.Update()
Catch except As Exception
Label2.Text = except.ToString()
End Try
End Sub
Page Code:
<asp:sqldatasource id="SqlDataSource1" runat="server"
="" connectionstring="<%$ ConnectionStrings:AppDataConnectionString %>" deletecommand="DELETE FROM [ATCSZ] WHERE [ID] = ?" insertcommand="INSERT INTO [ATCSZ] ([ID], [Address]) VALUES (?, ?)" providername="<%$ ConnectionStrings:AppDataConnectionString.ProviderName %>" selectcommand="SELECT [ID], [Address] FROM [ATCSZ]" updatecommand="UPDATE [ATCSZ] SET [Address] = ? WHERE [ID] = ?">
<deleteparameters>
<asp:parameter name="ID" type="Int32">
<updateparameters>
<asp:controlparameter name="Address" controlid="AddressTextBox" propertyname="Text">
<asp:controlparameter name="ID" controlid="IDTextBox" propertyname="Text">
<insertparameters>
<asp:parameter name="ID" type="Int32">
<asp:parameter name="Address" type="String">
<asp:label id="Label2" runat="server" style="position: relative">
ID:
<asp:textbox id="IDTextBox" runat="server" style="position: relative">
ADDRESS:<asp:textbox id="AddressTextBox" runat="server" style="position: relative">
<asp:button id="UpdateButton" runat="server" style="position: relative" text="UpdateData">
|
|
|
|
|
Try using
if ispostback = false
Dim ID As Integer = 2
Dim aTable As New ATSCZDSTableAdapters.ATCSZTableAdapter
Dim aRecords As ATSCZDS.ATCSZDataTable
Dim aRecord As ATSCZDS.ATCSZRow
aRecords = aTable.GetData(ID)
For Each aRecord In aRecords
Try
IDTextBox.Text = aRecord.ID
AddressTextBox.Text = aRecord.Address
Catch ex As Exception
Label2.Text = ex.ToString()
End Try
Next
end if
I didn't get any requirements for the signature
|
|
|
|
|
It Works! Forgot a simple little rule, didn't I?!
|
|
|
|
|
How can we connect the ASP.NET (2005)application to SQL Server 2000. Please send me the code to connect db and insert data into it.
|
|
|
|
|
|
I want to create a separate class that defines the db connections. then call it in my application(ASP.NET 2005). so pls send me the code For SQL connection and also the code to call the class in the code behind in a submit button click.
|
|
|
|
|
Hello
i have a asp.net application with subfolder:
www.myapplication.com/ressourcefolder/
I have disable anonymous access to ressourcefolder in IIS, If i try to access to this folder in internet explorer i have the authentication window.
Now i want my website to access to this folder witout opening the authentication window on client side.
How do this?
Thanks
|
|
|
|
|
enable integrated security on the folder.
make sure the windows account has access to the folder.
Add the site to the trusted sites list on the client.
I didn't get any requirements for the signature
|
|
|
|
|
|
If you want to suppress the authentication window at client it can be done through clients browser settings Tools--> Internet Options --> Security and select the zone of your site ie if client is accessing your site through intranet then select intranet and click on Custom Level Button and scroll down the list to Authentication and under logon select autiomatically login in intranet zone.
However these settings are to be made at client machine I belive there is nothing that can be done for it at server side
Shujaat
|
|
|
|
|
I am attempting to port an asp site which uses reference to wsc files; for example
objMyObject = Server.CreateObject("MyFile.WSC");
over to c#/net, how do I use the existing wsc file from .net?
I have already looked at using tlbImp.exe to affect a com iterop, but this produced an error.
Thanks
|
|
|
|
|
I grabbed the gridview control onto design page and then binded it with the database. Now I want to enter data in the grid view when i run the website but i cannot find the way to do that. How can this be done? Any guidance please or show me the code or way to do that.
Thanks
|
|
|
|
|
Be more clear, you mean, that your gridview read well the data from the database, but you can't add new records?
did you bind the gridwiew to a sqlDataSource?
|
|
|
|
|
yes i can see the data which has been added from SQL Server DB but how I can add manually?
Yes I binded gridview to SQL Data Source.
|
|
|
|
|
ok, when you bind the sqlDatasource. if you want enable edit and adding, you have to make when you are configuring the sqldatasource, in the box you select the columns you want to show from the database, there are three botton, Where, orden by and Advanced click the last one, Advanced, and check the first box "generate inset up........
and bind again your grid view to the sqldatasource.
and play with the grid view setting to make enable edit and adding.
hope that will help
|
|
|
|
|
I can see edit option but no ADD option. How can this be done?
|
|
|
|
|