Showing posts with label gridview. Show all posts
Showing posts with label gridview. Show all posts

Saturday, March 31, 2012

Text box and Gridview on same page

How do I get the validation not to fire if I'm updating a gridview on
the page. When I try to update the item in the gridview the text box
won't allow me to update because of its validation set for that text
box. How do I get around this I need the validation on the text box
too. Here's my page.
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<center style="color: #006666">
<strong><span style="font-family: Arial; text-decoration:
underline">
Add a Topic</span></strong></center>
<center>
<asp:Label ID="Lbloutcome1" runat="server" ForeColor="Red"></
asp:Label> </center>
<center>
<asp:TextBox ID="TopicTxt" runat="server" TextMode="MultiLine"
Width="334px" EnableViewState="False" CausesValidation="True"></
asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="TopicTxt"
ErrorMessage="Enter a Topic">
*</asp:RequiredFieldValidator><br />
<asp:Label ID="LblMsg" runat="server"></asp:Label><br />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" /
>
<br />
<asp:Button ID="Button1" runat="server" Text="Submit" />
<asp:Button ID="Button2" runat="server" Text="Reset"
CausesValidation="False" />
<br />
<br />
<asp:Label ID="Lbloutcome" runat="server" ForeColor="Red"
Width="237px"></asp:Label><br />
<asp:Label ID="Lbloutcome3" runat="server" ForeColor="Red"></
asp:Label><br />
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataKeyNames="classificationid"
DataSourceID="TopicsSqlDataSource"
AutoGenerateEditButton="True" BorderColor="#8E7953" BorderWidth="1px"
Width="209px" EnableViewState="False">
<Columns>
<asp:TemplateField HeaderText="Topic"
SortExpression="description">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("description") %>' Height="46px" Width="239px"></
asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<
%# Bind("description") %>'></asp:Label>
</ItemTemplate>
<ItemStyle BorderColor="#8E7953"
BorderStyle="Solid" />
<HeaderStyle BorderColor="#8E7953" Font-
Bold="True" Font-Size="Large" ForeColor="#006666" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete Topic"
InsertVisible="False" SortExpression="classificationid">
<ItemTemplate>
<asp:Label ID="classificationid"
runat="server" Font-Bold="True" Text='<%# DataBinder.Eval
(Container.DataItem, "classificationID") %>'
Visible="False"></asp:Label>
<asp:CheckBox ID="deleteRec" runat="server"
Font-Bold="True" />
</ItemTemplate>
<ItemStyle BorderColor="#8E7953" />
<HeaderStyle BorderColor="#8E7953" Font-
Bold="True" Font-Size="Large" ForeColor="#006666" />
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<br />
<asp:Button ID="Button3" runat="server" Text="Delete
Topic" CausesValidation="False" /><br />
<br />
<br />
<strong><span style="font-size: 14pt; color: #006666; font-
family: Arial; text-decoration: underline">
</span></strong>
<br />
<a href="http://links.10026.com/?link=AddTitle_Description.aspx" id="AddResourceAdminLink"
runat="server">Add a Resource</a><br />
<br />
<a href="http://links.10026.com/?link=EditResoureLibrary.aspx" id="EditResourceAdminLink"
runat="server">Edit Resource Library Information</a><br />
<br />
<br />
<table>
<tr>
<td style="width: 100px">
<a href="http://links.10026.com/?link=http://philanet/">
<img alt="PhilaNet" border="0" src="http://pics.10026.com/?src=Images/
philanet_small.gif" /></a></td>
<td style="width: 175px">
<a href="http://links.10026.com/?link=ResourceLibrary.aspx"><strong><span
style="font-size: 14pt">Resource Library</span></strong></a></td>
</tr>
</table>
<br />
<asp:SqlDataSource ID="TopicsSqlDataSource"
runat="server" ConnectionString="<%$
ConnectionStrings:TrainUserConnectionStr
ing %>"
SelectCommand="GetClassifications"
SelectCommandType="StoredProcedure" UpdateCommand="UpdateTopic"
UpdateCommandType="StoredProcedure">
<UpdateParameters>
<asp:Parameter Name="classificationID" Type="Int32" />
<asp:Parameter Name="description" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
</center>
</asp:Content>Checkout the ValidationGroup property.
"JJ297" <nc297@.yahoo.com> wrote in message
news:1194986781.386224.323330@.o3g2000hsb.googlegroups.com...
> How do I get the validation not to fire if I'm updating a gridview on
> the page. When I try to update the item in the gridview the text box
> won't allow me to update because of its validation set for that text
> box. How do I get around this I need the validation on the text box
> too. Here's my page.
> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
> Runat="Server">
> <center style="color: #006666">
> <strong><span style="font-family: Arial; text-decoration:
> underline">
> Add a Topic</span></strong></center>
> <center>
> <asp:Label ID="Lbloutcome1" runat="server" ForeColor="Red"></
> asp:Label> </center>
> <center>
> <asp:TextBox ID="TopicTxt" runat="server" TextMode="MultiLine"
> Width="334px" EnableViewState="False" CausesValidation="True"></
> asp:TextBox>
> <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
> runat="server" ControlToValidate="TopicTxt"
> ErrorMessage="Enter a Topic">
> *</asp:RequiredFieldValidator><br />
> <asp:Label ID="LblMsg" runat="server"></asp:Label><br />
> <asp:ValidationSummary ID="ValidationSummary1" runat="server" /
> <br />
> <asp:Button ID="Button1" runat="server" Text="Submit" />
> <asp:Button ID="Button2" runat="server" Text="Reset"
> CausesValidation="False" />
> <br />
> <br />
> <asp:Label ID="Lbloutcome" runat="server" ForeColor="Red"
> Width="237px"></asp:Label><br />
> <asp:Label ID="Lbloutcome3" runat="server" ForeColor="Red"></
> asp:Label><br />
> <asp:GridView ID="GridView1" runat="server"
> AutoGenerateColumns="False" DataKeyNames="classificationid"
> DataSourceID="TopicsSqlDataSource"
> AutoGenerateEditButton="True" BorderColor="#8E7953" BorderWidth="1px"
> Width="209px" EnableViewState="False">
> <Columns>
> <asp:TemplateField HeaderText="Topic"
> SortExpression="description">
> <EditItemTemplate>
> <asp:TextBox ID="TextBox1" runat="server"
> Text='<%# Bind("description") %>' Height="46px" Width="239px"></
> asp:TextBox>
> </EditItemTemplate>
> <ItemTemplate>
> <asp:Label ID="Label1" runat="server" Text='<
> %# Bind("description") %>'></asp:Label>
> </ItemTemplate>
> <ItemStyle BorderColor="#8E7953"
> BorderStyle="Solid" />
> <HeaderStyle BorderColor="#8E7953" Font-
> Bold="True" Font-Size="Large" ForeColor="#006666" />
> </asp:TemplateField>
> <asp:TemplateField HeaderText="Delete Topic"
> InsertVisible="False" SortExpression="classificationid">
> <ItemTemplate>
> <asp:Label ID="classificationid"
> runat="server" Font-Bold="True" Text='<%# DataBinder.Eval
> (Container.DataItem, "classificationID") %>'
> Visible="False"></asp:Label>
> <asp:CheckBox ID="deleteRec" runat="server"
> Font-Bold="True" />
> </ItemTemplate>
> <ItemStyle BorderColor="#8E7953" />
> <HeaderStyle BorderColor="#8E7953" Font-
> Bold="True" Font-Size="Large" ForeColor="#006666" />
> </asp:TemplateField>
> </Columns>
> </asp:GridView>
> <br />
> <br />
> <asp:Button ID="Button3" runat="server" Text="Delete
> Topic" CausesValidation="False" /><br />
> <br />
> <br />
> <strong><span style="font-size: 14pt; color: #006666; font-
> family: Arial; text-decoration: underline">
> </span></strong>
> <br />
> <a href="http://links.10026.com/?link=AddTitle_Description.aspx" id="AddResourceAdminLink"
> runat="server">Add a Resource</a><br />
> <br />
> <a href="http://links.10026.com/?link=EditResoureLibrary.aspx" id="EditResourceAdminLink"
> runat="server">Edit Resource Library Information</a><br />
> <br />
> <br />
> <table>
> <tr>
> <td style="width: 100px">
> <a href="http://links.10026.com/?link=http://philanet/">
> <img alt="PhilaNet" border="0" src="http://pics.10026.com/?src=Images/
> philanet_small.gif" /></a></td>
> <td style="width: 175px">
> <a href="http://links.10026.com/?link=ResourceLibrary.aspx"><strong><span
> style="font-size: 14pt">Resource Library</span></strong></a></td>
> </tr>
> </table>
> <br />
> <asp:SqlDataSource ID="TopicsSqlDataSource"
> runat="server" ConnectionString="<%$
> ConnectionStrings:TrainUserConnectionStr
ing %>"
> SelectCommand="GetClassifications"
> SelectCommandType="StoredProcedure" UpdateCommand="UpdateTopic"
> UpdateCommandType="StoredProcedure">
> <UpdateParameters>
> <asp:Parameter Name="classificationID" Type="Int32" />
> <asp:Parameter Name="description" Type="String" />
> </UpdateParameters>
> </asp:SqlDataSource>
> <br />
> </center>
> </asp:Content>
>
On Nov 13, 4:02 pm, "J055" <j...@.newsgroups.nospam> wrote:
> Checkout the ValidationGroup property.
> "JJ297" <nc...@.yahoo.com> wrote in message
> news:1194986781.386224.323330@.o3g2000hsb.googlegroups.com...
>
>
>
>
> - Show quoted text -
Thanks it worked!

Text Box to search contents in a Gridview Control

Hello,
I have seen several examples with a dropdownlist filtering the results in a
gridview.
Is there a way to have information typed in a text box used to filter a
gridview?
I would like to for example search on a persons first name and any first
name that contains the contents of my text box appear in the gridview list.The datasource object selectParameters allows you to use the ControlParamete
r
against a TextBox, e.g.
<asp:ControlParameter ControlID="txtCustomer" Name="CustomerID"
PropertyName="Text" Type="String" />
This sample uses a dropdownlist box:
http://www.webswapp.com/CodeSamples...ridView_2c.aspx
and this sample does the same exact filtering using a TextBox:
http://www.webswapp.com/CodeSamples...ridView_3c.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"mimo" wrote:
> Hello,
> I have seen several examples with a dropdownlist filtering the results in
a
> gridview.
> Is there a way to have information typed in a text box used to filter a
> gridview?
> I would like to for example search on a persons first name and any first
> name that contains the contents of my text box appear in the gridview list.[/color
]

Text Box to search contents in a Gridview Control

Hello,

I have seen several examples with a dropdownlist filtering the results in a
gridview.

Is there a way to have information typed in a text box used to filter a
gridview?

I would like to for example search on a persons first name and any first
name that contains the contents of my text box appear in the gridview list.The datasource object selectParameters allows you to use the ControlParameter
against a TextBox, e.g.
<asp:ControlParameter ControlID="txtCustomer" Name="CustomerID"
PropertyName="Text" Type="String" /
This sample uses a dropdownlist box:
http://www.webswapp.com/CodeSamples...ridView_2c.aspx
and this sample does the same exact filtering using a TextBox:
http://www.webswapp.com/CodeSamples...ridView_3c.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com

"mimo" wrote:

> Hello,
> I have seen several examples with a dropdownlist filtering the results in a
> gridview.
> Is there a way to have information typed in a text box used to filter a
> gridview?
> I would like to for example search on a persons first name and any first
> name that contains the contents of my text box appear in the gridview list.

Wednesday, March 28, 2012

text encoding problem in GridView .Net 2.0

Hi guys!
i've got very interesting problem. the problem is like this.
i've 2 webpages.
-- page1 contains DataGrid control of .Net 1.1 and
-- Page2 contains GridView control of .Net 2.0.
-- both grid displays same data and same function is used to fetch data
from the database.
the grid on Page1 displays data correctly but i've got problem with the
grid of Page2.
in one column which shows NVARCHAR data,
the data shown on Page1 is like this
ab=E6cd=F8ef=E5
and the same text is diaplyed differently on Page2 Grid like this,
abæcdøefå
it seems problem with encoding but i'm not able to find out how to fix
this.
i'm using C#.NET 2.0 and MS SQL SERVER 2000
can anyone help me out here? i would appriciate it.
Thanks,
Luckyhi guys!
again me. i found the problem. it wasn't with the GridView. so do not
bother about this.
Lucky
Lucky wrote:
> Hi guys!
> i've got very interesting problem. the problem is like this.
> i've 2 webpages.
> -- page1 contains DataGrid control of .Net 1.1 and
> -- Page2 contains GridView control of .Net 2.0.
> -- both grid displays same data and same function is used to fetch data
> from the database.
> the grid on Page1 displays data correctly but i've got problem with the
> grid of Page2.
> in one column which shows NVARCHAR data,
> the data shown on Page1 is like this
> ab=E6cd=F8ef=E5
> and the same text is diaplyed differently on Page2 Grid like this,
> abæcdøefå
> it seems problem with encoding but i'm not able to find out how to fix
> this.
> i'm using C#.NET 2.0 and MS SQL SERVER 2000
> can anyone help me out here? i would appriciate it.
>=20
> Thanks,
> Lucky
hi guys!
again me. i found the problem. it wasn't with the GridView. so do not
bother about this.
Lucky
Lucky wrote:
> Hi guys!
> i've got very interesting problem. the problem is like this.
> i've 2 webpages.
> -- page1 contains DataGrid control of .Net 1.1 and
> -- Page2 contains GridView control of .Net 2.0.
> -- both grid displays same data and same function is used to fetch data
> from the database.
> the grid on Page1 displays data correctly but i've got problem with the
> grid of Page2.
> in one column which shows NVARCHAR data,
> the data shown on Page1 is like this
> ab=E6cd=F8ef=E5
> and the same text is diaplyed differently on Page2 Grid like this,
> abæcdøefå
> it seems problem with encoding but i'm not able to find out how to fix
> this.
> i'm using C#.NET 2.0 and MS SQL SERVER 2000
> can anyone help me out here? i would appriciate it.
>=20
> Thanks,
> Lucky

Text file

In my table, there is a field which stores the path of a text file (C:\\story.txt).

when i want to retrieve that table with gridview, i want that field will show the all text written in that text file. I mean not the path (C:\\story.txt). Instead it will grab all the text written in that text file. How can i do this?


using (StreamReader stream =newStreamReader(@."c:\story.txt"))

{

string fileContents = stream.ReadToEnd();

}


Plus make sure that ASPNET account as read access to C:/ directory.

HC