16,004,686 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 10578683 (Top 200 by date)
Member 10578683
2-Apr-15 7:16am
View
my Button2 is present in popup window and ImageButton10 present in parent page
Member 10578683
2-Apr-15 6:36am
View
document.getElementById('<%=ImageButton10.ClientID%>').Click();
On writing this an error ImageButton10 does not exit in current context is showing
Member 10578683
18-Mar-15 7:44am
View
I am not understanding how will I register the assembly of time picker
Member 10578683
16-Feb-15 2:43am
View
yes I have put the getElementById result in textbox1 and textbox2
Member 10578683
16-Feb-15 2:32am
View
hmm. Error is coming in the line
if ((txtbox1.value == txtbox2.value) && (i != j)) {
Member 10578683
11-Feb-15 2:07am
View
Month GatePassNo Paroduct_nmae SerialNo Pending Repaired Replace
January qqq RAM rttt 1 0 1
January rrr Mouse hhhh 2 1 1
February aaa SMPS aaa 0 1 1
Like this it is coming but i want
January qqq RAM rttt 1 0 1
rrr Mouse hhhh 2 1 1
February aaa SMPS aaa 0 1 1
like this it should come
Member 10578683
11-Feb-15 1:53am
View
I want to write a nested query from the above query so that i will get all the details according to month. month should be the parent group and all details comes as child group. don't know how to design the query. kindly help
Member 10578683
10-Feb-15 8:21am
View
ya after that also it is not coming
Member 10578683
5-Feb-15 2:59am
View
I want to say that when the alert box appears then the main page on which this appears is blank. i.e on a blank white page the alert box appears. when i am clicking the ok button of alert box then the main page appears. i want to see the main page always
Member 10578683
14-Jan-15 5:45am
View
It is showing error as
28 C:\Users\swetad\Desktop\Output\main.cpp:19 no match for 'operator!=' in 'file.std::basic_ifstream<char>::<anonymous>.std::basic_istream<_CharT, _Traits>::get [with _CharT = char, _Traits = std::char_traits<char>, std::basic_istream<_CharT, _Traits>::char_type = char]((* & letter)) != -0x000000001'
Member 10578683
8-Jan-15 3:56am
View
Thanks
Member 10578683
6-Jan-15 6:31am
View
Thank u. ii is working now.
Member 10578683
11-Dec-14 3:26am
View
Thank you
Member 10578683
26-Nov-14 5:53am
View
<script type="text/javascript" language="javascript">
function checkDate(sender, args) {
var toDate = new Date();
toDate.setMinutes(0);
toDate.setSeconds(0);
toDate.setHours(0);
toDate.setMilliseconds(0);
//var diff = sender._selectedDate - toDate;
if (sender._selectedDate - toDate > 7) {
alert("You cannot select past date more than 1 week!");
sender._selectedDate = toDate;
// set the date back to the current date
sender._textbox.set_Value(sender._selectedDate.format(sender._format))
}
}
</script>
I wrote like this but it is not working. showing the alert msg when I m selecting a future date
Member 10578683
15-Oct-14 4:32am
View
Clearly i want to fire textchanged event first before adding
Member 10578683
9-Oct-14 8:35am
View
yes
Member 10578683
9-Oct-14 3:59am
View
-- the content has been moved --
Member 10578683
9-Oct-14 3:51am
View
I want at first the text changed event of textbox should work first before button_click event
Member 10578683
9-Oct-14 3:49am
View
<asp:Button ID="Button2" runat="server" BackColor="#F4F4F4" CssClass="style4"
Font-Size="8.5pt" Height="22px" onclick="Button2_Click" Text="Add to GatePass"
OnClientClick="javascript:return ValidateField()" Font-Bold="False"
Width="120px" />
Member 10578683
26-Sep-14 6:43am
View
Thank U Very much
Member 10578683
16-Sep-14 6:12am
View
Deleted
ok
Member 10578683
8-Sep-14 4:10am
View
Thank U. this is exactly the same I want
Member 10578683
8-Sep-14 4:02am
View
con.Open();
string query2 = "update TOP(1) Inventory set P='" + Label29.Text + "' where [Product]='" + Product.Text + "' and Status='" + Status.Text + "'";
SqlCommand cmd = new SqlCommand(query2, con);
cmd.ExecuteNonQuery();
con.Close();
Hello sorry to not give u proper information
This is my code. Instead of updating the TOP(1) row I want to UPDATE that number of row that are in textbox
Member 10578683
3-Sep-14 3:06am
View
I did like this but not changing
Member 10578683
27-Aug-14 3:36am
View
when i am moving from one checkbox to other it is not appearing . on a button click it is appearing
Member 10578683
27-Aug-14 3:32am
View
i did like this but it is not working
Member 10578683
27-Aug-14 2:52am
View
before button click how this custom validator will validate on every postback
Member 10578683
27-Aug-14 2:16am
View
Thanks. It is working now.I forgot to write validation group.
Member 10578683
26-Aug-14 9:45am
View
this is also not working. i didn't gen anything. it is not comparing
Member 10578683
26-Aug-14 9:27am
View
<asp:CustomValidator ID="CustomValidator1" runat="server"
ValidateEmptyText="true" ValidationGroup="txt"
ErrorMessage="please enter correct no. of serial number" OnServerValidate="CustomValidator1_ServerValidate" >
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
CustomValidator cv = (CustomValidator)source;
GridViewRow gvr = (GridViewRow)cv.NamingContainer;
CheckBox chk = (CheckBox)gvr.FindControl("CheckBox1");
TextBox txt1 = (TextBox)gvr.FindControl("TextBox1");
TextBox txt2 = (TextBox)gvr.FindControl("TextBox6");
string serials = txt2.Text;
string[] sl = serials.Split(',');
if (chk.Checked == true)
{
if (sl.Length == Convert.ToInt16(txt1.Text))
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}
}
Hello i wrote my code like this but it is not working
Member 10578683
26-Aug-14 8:28am
View
i don't know how to write a custom validator for the textboes present in gridview template field
Member 10578683
26-Aug-14 8:11am
View
how to use custom validator for the textboxes inside gridview
Member 10578683
22-Aug-14 4:43am
View
It is working now.
thanks to all
Member 10578683
22-Aug-14 4:35am
View
I wrote the code like this but it is not working protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i <= GridView1.Rows.Count; i++)
{
TextBox txt = (TextBox)GridView1.Rows[i].FindControl("TextBox2");
PlaceHolder ph = (PlaceHolder)GridView1.Rows[i].FindControl("PlaceHolder1");
for (int j = 0; j < Convert.ToInt32(txt.Text); j++)
{
ph.Controls.Add(new LiteralControl("<input id='txt' name='Textbox" + j + "'type='Text' />"));
ph.Controls.Add(new LiteralControl("<br/>"));
}
}
}
Member 10578683
22-Aug-14 4:08am
View
no
Member 10578683
22-Aug-14 3:31am
View
I know how to dynamically generate the textboxes bt i dont know how on pressing enter key the textboes will generate.
public void fun1()
{
if (TextBox2.Text != "")
{
for (int i = 0; i <= Convert.ToInt16(TextBox2.Text) / 3; i++)
{
Label la = new Label();
la.Text = DropDownList2.SelectedItem.Value + (i + 1).ToString();
la.ID = "abc1" + i;
Panel3.Controls.Add(la);
//la = FindControl(String.Format(i)) as Label;
// TextBox Textbox = new TextBox();
// Textbox.ID = "txt" + i.ToString();
// txtbox.Text = "Textbox - " + i.ToString();
Panel3.Controls.Add(new LiteralControl("<input id='txt' name='Textbox" + i + "'type='Text' />"));
Panel3.Controls.Add(new LiteralControl("<br/>"));
}
for (int j = (Convert.ToInt16(TextBox2.Text) / 3) + 1; j <= Convert.ToInt16(TextBox2.Text) * 2 / 3; j++)
{
Label la1 = new Label();
la1.Text = DropDownList2.SelectedItem.Value + (j + 1).ToString();
la1.ID = "abc2" + j;
Panel4.Controls.Add(la1);
Panel4.Controls.Add(new LiteralControl("<input id='txt2' name='Textbox" + j + "'type='Text' />"));
Panel4.Controls.Add(new LiteralControl("<br/>"));
}
for (int k = (Convert.ToInt16(TextBox2.Text) * 2 / 3) + 1; k < Convert.ToInt16(TextBox2.Text); k++)
{
Label la2 = new Label();
la2.Text = DropDownList2.SelectedItem.Value + (k + 1).ToString();
la2.ID = "abc3" + k;
Panel5.Controls.Add(la2);
Panel5.Controls.Add(new LiteralControl("<input id='txt3' name='Textbox" + k + "'type='Text' />"));
Panel5.Controls.Add(new LiteralControl("<br/>"));
}
}
}
Member 10578683
20-Aug-14 2:53am
View
Thank You Very Much. I exactly want to do this.
Member 10578683
6-Aug-14 1:48am
View
Hello
for (var i = 0; i <= 20; i++) {
var txtbox = document.getElementById("Textbox" + i)
if (txtbox) {
if ( txtbox.value == "") {
alert("Serial Number field cannot be empty");
return false;
}
I wrote the code like above. It is working fine but problem is it is taking space. how to trim the text box. when i write Trim() it is showing error. please help
Member 10578683
30-Jul-14 3:28am
View
Thanks
Member 10578683
30-Jul-14 3:28am
View
Thanks
Member 10578683
25-Jul-14 1:43am
View
Thanks. I will try it.
Member 10578683
24-Jul-14 10:01am
View
I have created dynamic textboexes. If that textboxes empty then it should give a alert msg as Enter serial Number. I have wrote the javascript code for that. But this code is showing the alert message when the first textbox of the placeholders are empty. It is not checking all the dynamic generated textboxes.
my code is as follows
public void fun1()
{
if (txtQuantity.Text != "")
{
for (int i = 0; i <= Convert.ToInt16(txtQuantity.Text) / 3; i++)
{
Label la = new Label();
la.Text = ddlProductName.SelectedItem.Value + (i + 1).ToString();
la.ID = "abc1" + i;
PlaceHolder1.Controls.Add(la);
//la = FindControl(String.Format(i)) as Label;
TextBox txtbox = new TextBox();
// txtbox.Text = "Textbox - " + i.ToString();
PlaceHolder1.Controls.Add(new LiteralControl("<input id='txt' name='Textbox" + i + "'type='Text' />"));
PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));
}
for (int j = (Convert.ToInt16(txtQuantity.Text) / 3) + 1; j <= Convert.ToInt16(txtQuantity.Text) * 2 / 3; j++)
{
Label la1 = new Label();
la1.Text = ddlProductName.SelectedItem.Value + (j + 1).ToString();
la1.ID = "abc2" + j;
PlaceHolder2.Controls.Add(la1);
//la = FindControl(String.Format(i)) as Label;
TextBox txtbox1 = new TextBox();
// txtbox.Text = "Textbox - " + i.ToString();
PlaceHolder2.Controls.Add(new LiteralControl("<input id='txt2' name='Textbox" + j + "'type='Text' />"));
PlaceHolder2.Controls.Add(new LiteralControl("<br/>"));
}
for (int k = (Convert.ToInt16(txtQuantity.Text) * 2 / 3) + 1; k < Convert.ToInt16(txtQuantity.Text); k++)
{
Label la2 = new Label();
la2.Text = ddlProductName.SelectedItem.Value + (k + 1).ToString();
la2.ID = "abc3" + k;
PlaceHolder3.Controls.Add(la2);
//la = FindControl(String.Format(i)) as Label;
TextBox txtbox1 = new TextBox();
// txtbox.Text = "Textbox - " + i.ToString();
PlaceHolder3.Controls.Add(new LiteralControl("<input id='txt3' name='Textbox" + k + "'type='Text' />"));
PlaceHolder3.Controls.Add(new LiteralControl("<br/>"));
}
}
}
Member 10578683
24-Jul-14 2:18am
View
Hi,
I wrote the client side code for the problem of postback. But it is working for the first dynamic textbox of all the placeholder. I am not able to know why it is not checking all the dynamically generated textboxes. My code isas follows
if (document.getElementById("txt") == "") {
alert("Please enter Serial Number");
document.getElementById("txt").focus();
return false;
}
if (document.getElementById("txt2").value == "") {
alert("Please enter Serial Number");
document.getElementById("txt2").focus();
return false;
}
if (document.getElementById("txt3").value == "") {
alert("Please enter Serial Number");
document.getElementById("txt3").focus();
return false;
}
Please help
Member 10578683
23-Jul-14 7:36am
View
Thanks I will try it.
Member 10578683
23-Jul-14 7:17am
View
Thanks. it is working correctly now. but problem is on postback the textboxes dissappears. when i call the function create textbox in the Add button then the text boxes appearing but the value of the textboxes are disappearing. How to do it
Member 10578683
23-Jul-14 6:41am
View
if (txtQuantity.Text != "")
{
try
{
List<string> list = new List<string>();
for (int i = 0; i < quantity; i++)
{
list.Add(Request.Form["Textbox" + i.ToString()]);
if (Request.Form["Textbox"+i.ToString()]== "")
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Enter Serial Number');", true);
//Button2.Attributes.Add("onClick", "return false;");
}
}
for(int i =0;i<list.Count;i++)
{
if (list[i] != "")
// Label17.Visible = false;
con.Open();
string qryInsertProduct = "insert into Product_Details(GatePassNo,ClientID,Product_name,SerialNo,Status,CheckIN_Date ,Customer_Name, Customer_location, System_Date, [GatePass Status],State, City,S) values('" + GatePassNo + "','" + clientID + "','" + productName + "','" +list[i] + "','" + status + "','" + TextBox1.Text + "','" + ddlCName.SelectedItem.Value + "','" + ddlCLocation.SelectedItem.Value + "','" + Label11.Text + "', 'Open','" + DropDownList1.SelectedItem.Value + "','" + DropDownList2.SelectedItem.Value + "','0')";
SqlCommand comInsertProduct = new SqlCommand(qryInsertProduct, con);
comInsertProduct.ExecuteNonQuery();
con.Close();
gdvProducts.Visible = true;
PopulateGridView();
}
}
catch (Exception ex)
{
}
finally
{
if (con.State == ConnectionState.Open)
{
con.Close();
Member 10578683
23-Jul-14 6:08am
View
Hello. how to do it. i tried to do but getting error. Kindly give some code
Member 10578683
21-Jul-14 9:57am
View
It is not working correctly
Is there any server side code for this
Member 10578683
21-Jul-14 9:24am
View
Hello thank you for your reply. I wrote the code like this var elemArray = document.getElementsByName("TextBox");
for (var i = 0; i < elemArray.length; i++) {
if (document.getElementById(elemArray[i].id) == "") {
alert("Please enter Serial Number");
document.getElementById("txt").focus();
return false;
}
}
it is taking empty space. how to avoid space in the checkboes
Member 10578683
18-Jul-14 9:12am
View
if (txtQuantity.Text != "")
{
for (int i = 0; i <= Convert.ToInt16(txtQuantity.Text) / 3; i++)
{
Label la = new Label();
la.Text = ddlProductName.SelectedItem.Value + (i + 1).ToString();
la.ID = "abc1" + i;
PlaceHolder1.Controls.Add(la);
//la = FindControl(String.Format(i)) as Label;
TextBox txtbox = new TextBox();
// txtbox.Text = "Textbox - " + i.ToString();
PlaceHolder1.Controls.Add(new LiteralControl("<input id='txt' name='Textbox" + i + "'type='text' />"));
PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));
}
for (int j = (Convert.ToInt16(txtQuantity.Text) / 3) + 1; j <= Convert.ToInt16(txtQuantity.Text) * 2 / 3; j++)
{
Label la1 = new Label();
la1.Text = ddlProductName.SelectedItem.Value + (j + 1).ToString();
la1.ID = "abc2" + j;
PlaceHolder2.Controls.Add(la1);
//la = FindControl(String.Format(i)) as Label;
TextBox txtbox1 = new TextBox();
// txtbox.Text = "Textbox - " + i.ToString();
PlaceHolder2.Controls.Add(new LiteralControl("<input id='txt' name='Textbox" + j + "'type='text' />"));
PlaceHolder2.Controls.Add(new LiteralControl("<br/>"));
}
for (int k = (Convert.ToInt16(txtQuantity.Text) * 2 / 3) + 1; k < Convert.ToInt16(txtQuantity.Text); k++)
{
Label la2 = new Label();
la2.Text = ddlProductName.SelectedItem.Value + (k + 1).ToString();
la2.ID = "abc3" + k;
PlaceHolder3.Controls.Add(la2);
//la = FindControl(String.Format(i)) as Label;
TextBox txtbox1 = new TextBox();
// txtbox.Text = "Textbox - " + i.ToString();
PlaceHolder3.Controls.Add(new LiteralControl("<input id='txt' name='Textbox" + k + "'type='text' />"));
PlaceHolder3.Controls.Add(new LiteralControl("<br/>"));
}
}
Member 10578683
18-Jul-14 9:11am
View
now it is working fine. if (document.getElementById("txt").value.toString().trim() == "") {
alert("Please enter Serial Number");
document.getElementById("txt").focus();
return false;
I wrote the code this way. but the problem is this is working fine for one textbox which is generating first in out of the dynamic textboxes
Member 10578683
18-Jul-14 9:05am
View
in this code the alert message is not appearing
Member 10578683
14-Jul-14 7:55am
View
yes i am calling these methods in page load as follows
if (!Page.IsPostBack)
{
//GridView1.Visible = false;
//lblCurrentDate.Text = DateTime.Now.ToString();
BindCName();
BindCLocation();
}
Member 10578683
14-Jul-14 7:43am
View
<td class="style107" valign="top" colspan="2">
<asp:DropDownList ID="ddlCName" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="ddlCName_SelectedIndexChanged" CssClass="style168"
Height="30px" Width="150px" BackColor="White" Font-Size="8.5pt" ViewStateMode="Enabled">
</td>
<td class="style160" valign="top">
<asp:Label ID="lblH3" runat="server" Text="Customer Location" CssClass="style169"
Font-Size="8.5pt" ForeColor="Black">
</td>
<td class="style162" valign="top" colspan="2">
<asp:DropDownList ID="ddlCLocation" runat="server" CssClass="style168"
Height="30px" Width="150px" BackColor="White" Font-Size="8.5pt" ViewStateMode="Enabled" >
Member 10578683
14-Jul-14 5:41am
View
public void BindCName()
{
string qry = "select distinct Customer_Name from Customer_Details";
DataSet ds = du.GetDataSet(qry);
ddlCName.DataSource = ds;
ddlCName.DataTextField = "Customer_Name";
ddlCName.DataValueField = "Customer_Name";
ddlCName.DataBind();
ddlCName.Items.Insert(0, "<--Select-->");
ddlCName.Items[0].Value = "";
}
public void BindCLocation()
{
string qry = "select distinct Customer_Location from Customer_Details";
DataSet ds = du.GetDataSet(qry);
ddlCLocation.DataSource = ds;
ddlCLocation.DataTextField = "Customer_Location";
ddlCLocation.DataValueField = "Customer_Location";
ddlCLocation.DataBind();
ddlCLocation.Items.Insert(0, "<--Select-->");
ddlCLocation.Items[0].Value = "";
}
Member 10578683
14-Jul-14 5:40am
View
ya i enabled view state still it is notworking
Member 10578683
14-Jul-14 5:23am
View
no
Member 10578683
11-Jul-14 4:36am
View
Thank You. Pheonyx. I modified your code and got what i want. Thank you very much for giving a nice idea
Member 10578683
10-Jul-14 8:45am
View
I am not getting the right answer of this problem.That's why i am posting this again and again to get a right solution. can you give the right solution.
Member 10578683
10-Jul-14 7:53am
View
i am not getting any value kindly help
Member 10578683
10-Jul-14 7:26am
View
the datasource have null value
Member 10578683
10-Jul-14 6:59am
View
It is not working correctly
Member 10578683
10-Jul-14 6:13am
View
It is not exactly SMPS And motherboard. It may be any product Name like SMPS, MotherBard, RAM or SMPS,Joystick like this. i m just give an example for understanding
Member 10578683
10-Jul-14 5:32am
View
It is working fine.Thank you Very much
Member 10578683
10-Jul-14 4:23am
View
Thanks
Member 10578683
10-Jul-14 3:34am
View
How to get this information. Please help
Member 10578683
10-Jul-14 3:29am
View
I forgot to put that column name there after Product Serial Number column is there in database
Member 10578683
7-Jul-14 2:50am
View
Thanks Chill. I modified your code a little and it is working fine. Thank you Very much.
Member 10578683
7-Jul-14 1:42am
View
It is not working. It is showing String does not contain a definition of Mid
Member 10578683
7-Jul-14 1:33am
View
Yes you are right but u have written this code for particular assets such as joystick and RAM. but in general how will i do it for any asset type
Member 10578683
5-Jul-14 7:44am
View
I think you are giving the VB code. I m doing in c#
Member 10578683
5-Jul-14 7:37am
View
It is showing error mid does not exis
Member 10578683
5-Jul-14 7:28am
View
showing error in the line mid(s1,2)
Member 10578683
5-Jul-14 6:55am
View
I have not the constant asset type. It varies. The string may contain 3 items or 4 items. how will i do in that case
Member 10578683
5-Jul-14 5:45am
View
It is not correctly working. Suppose in textbox RAM,joystick there then it should select the vendor name dgd but instead of that it is selecting Future India, dgd,rry
Member 10578683
4-Jul-14 8:54am
View
I have to write a query that select the vendor names that contains Battery and mouse.like this. but i am unable to form this type query. Kindly help
Member 10578683
4-Jul-14 7:48am
View
yes
Member 10578683
4-Jul-14 7:17am
View
Actually i need that vendor name that contains the assets present in my textbox.
Member 10578683
4-Jul-14 7:15am
View
Is there any other way to get the vendor name
Member 10578683
4-Jul-14 7:14am
View
It is working but it is showing all the vendor name.
Member 10578683
4-Jul-14 5:41am
View
It is showing error invalid column name S1
Member 10578683
3-Jul-14 2:37am
View
Thanks
Member 10578683
3-Jul-14 1:49am
View
please give the c#code
Member 10578683
2-Jul-14 10:05am
View
how will i get the common vendor name
Member 10578683
2-Jul-14 9:58am
View
Can you give some code for it.
Member 10578683
2-Jul-14 7:14am
View
this is my code.select VenderName from Venders where Asset in ('Asset1', 'Asset2'). In this query i want to know what will i write instead of Asset1, Asset 2 because every time i am selecting different assets from my grid view as assets are not fixed.
Member 10578683
2-Jul-14 7:11am
View
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chkUpdate = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox1");
if (chkUpdate != null)
{
if (chkUpdate.Checked)
{
con.Open();
Label ID = (Label)GridView1.Rows[i].FindControl("Label7");
Session["ID1"] = ID.Text;
Label GatePassNo = (Label)GridView1.Rows[i].FindControl("Label1");
Label Customer_Name = (Label)GridView1.Rows[i].FindControl("Label2");
Label Customer_Location = (Label)GridView1.Rows[i].FindControl("Label3");
Label Product_Name = (Label)GridView1.Rows[i].FindControl("Label4");
Session["Asst"] = Product_Name.Text;
Label SerialNo = (Label)GridView1.Rows[i].FindControl("Label5");
string query = "insert into VendorGatePass (Vendor_GatePass, Customer_Name, Customer_Location,Product_Name,Serial_Number)values('" + TextBox7.Text + "','" + Customer_Name.Text + "','" + Customer_Location.Text + "','" + Product_Name.Text + "','" + SerialNo.Text + "')";
SqlCommand com = new SqlCommand(query, con);
// con.Open();
com.ExecuteNonQuery();
SqlCommand comm = new SqlCommand("select [Asset_Type] from abc where ID='" + ID.Text + "' ", con);
SqlDataReader reade = comm.ExecuteReader();
// 2. define parameters used in command object
while (reade.Read())
{
Session["Asset_Type"] = Convert.ToString(reade["Asset_type"]);
}
// con.Close();
//Button Add = (Button)PreviousPage.FindControl("Button2");
con.Close();
string qry = "insert into abc (Asset_Type,ID)values('" + Product_Name.Text + "','" +ID.Text + "')";
SqlCommand comd = new SqlCommand(qry, con);
con.Open();
comd.ExecuteNonQuery();
string url = "Vendors.aspx";
string s = "window.open('" + url + "', 'popup_window', 'width=400,height=300,scrollbar=yes,direction=right,left=300,top=300,resizable=yes');";
ClientScript.RegisterStartupScript(this.GetType(), "script", s, true);
con.Close();
bindddl();
public void bindddl()
{
con.Open();
string qry = " Select Vendor_Name from vendor where Asset_Type='"+Session["Asset_Type"].ToString()+"'";
SqlDataAdapter adpt = new SqlDataAdapter(qry,con);
DataTable dt = new DataTable();
adpt.Fill(dt);
DropDownList4.DataSource= dt;
DropDownList4.DataBind();
DropDownList4.DataTextField="Vendor_Name";
DropDownList4.DataValueField="Vendor_Name";
con.Close();
}
Member 10578683
26-Jun-14 2:32am
View
I am not understanding what u r saying . Please kindly mention the details why this error is coming and how to write code for this in Detail. If any link you have please share.
Member 10578683
21-Jun-14 2:59am
View
but in my code it is showing error and i need to generate the textboxes on button click
Member 10578683
20-Jun-14 7:20am
View
I mean the textboes are generating but when i am clicking other buttons the textboxes disappearing.
Member 10578683
20-Jun-14 7:07am
View
ya i tried but not working
Member 10578683
2-Jun-14 8:23am
View
I need the qyery to upload all the states and their corresponding cities in database
Member 10578683
19-May-14 3:37am
View
I have to display the elements in the list in a dialog box after clicking the image button in gridview
Member 10578683
19-May-14 3:36am
View
It is only one record is fetching from database
Member 10578683
1-May-14 7:55am
View
nothing to update i just want to insert those Asset_type that is not in the db
Member 10578683
1-May-14 7:54am
View
No no it is wrongly commented
Member 10578683
1-May-14 1:35am
View
Thanks
Member 10578683
28-Apr-14 4:49am
View
When i am assigning ID then it is showing error
Multiple controls with the same ID 'link1' were found. FindControl requires that controls have unique IDs.
But i have created one ID link1 and adding one control to it
Member 10578683
24-Apr-14 3:36am
View
how will i make the CSS browser compartible
Member 10578683
21-Apr-14 2:52am
View
that condition is not executing
Member 10578683
21-Apr-14 2:35am
View
i did like this but not coming. please check the code
protected void gdvProducts_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.Footer)
{
}
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
string txt_ddlStatus = e.Row.FindControl("ddlStatus").ClientID;
string txt_ddlSubStatus = e.Row.FindControl("ddlSubStatus").ClientID;
ImageButton lnlUpdate = (ImageButton)e.Row.FindControl("lnkUpdate");
lnlUpdate.Attributes.Add("onclick", "javascript:return Validate('" + txt_ddlStatus + "','" + txt_ddlSubStatus + "')");
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblId = (Label)e.Row.FindControl("lblID");
string id = lblId.Text;
Label lblProductName = (Label)e.Row.FindControl("lblProduct");
Label lblSerial = (Label)e.Row.FindControl("lblSerial");
Label lblStatus = (Label)e.Row.FindControl("lblStatus");
TextBox txtBox1 = (TextBox)PlaceHolder1.FindControl("tb1");
string subProductName = lblProductName.Text;
string subSerial = lblSerial.Text;
string subStatus = lblStatus.Text;
if (Session["Role"] != null && !string.IsNullOrEmpty(Session["Role"].ToString()))
{
con.Open();
using (SqlCommand comm = new SqlCommand("select [Edit] from Role1 where Role_Name=@Role and Pages=@Pages", con))
{
string Role = (string)(Session["Role"]);
// 2. define parameters used in command object
SqlParameter para = null;
para = new SqlParameter();
para.ParameterName = "@Role";
para.Value = Role;
comm.Parameters.Add(para);
//Pass @Pages parameter
para = new SqlParameter();
para.ParameterName = "@Pages";
para.Value = "Checkin";
comm.Parameters.Add(para);
SqlDataReader reade = comm.ExecuteReader();
while (reade.Read())
{
Session["Edit"] = Convert.ToString(reade["Edit"]);
}
//Button Add = (Button)PreviousPage.FindControl("Button2");
if (Session["Edit"].ToString() == "Y")
{
ImageButton img = (ImageButton)e.Row.FindControl("lnkEdit");
img.Visible = true;
}
else
{
ImageButton img = (ImageButton)e.Row.FindControl("lnkEdit");
img.Visible = false;
}
}
}
con.Close();
}
}
catch (Exception ex)
{
}
}
and the mark up is
<itemtemplate>
<asp:ImageButton CssClass="txtBtn" ID="lnkEdit" runat="server" CommandName="Edit"
ImageUrl="~/images/edit.gif" ToolTip="Edit" />
<asp:ImageButton CssClass="txtBtn" ID="lnkDelete" runat="server" CommandName="Delete"
CommandArgument='' OnClientClick="javascript:return confirm('Are you sure you want to delete the record?')"
Member 10578683
19-Apr-14 7:47am
View
When the database contain Y in view field then a user who login can view the abc.aspx page. for that i need
Member 10578683
19-Apr-14 2:03am
View
No No i want to hide or show an aspx page.
I am giving u an example.In this case i am hide/show a button. similarly how will i make visible/hide a aspx page
if (Session["Role"] != null && !string.IsNullOrEmpty(Session["Role"].ToString()))
{
con.Open();
using (SqlCommand comm = new SqlCommand("select [Add] from Role1 where Role_Name=@Role and Pages=@Pages", con))
{
string Role = (string)(Session["Role"]);
// 2. define parameters used in command object
SqlParameter para = null;
para = new SqlParameter();
para.ParameterName = "@Role";
para.Value = Role;
comm.Parameters.Add(para);
//Pass @Pages parameter
para = new SqlParameter();
para.ParameterName = "@Pages";
para.Value = "Checkin";
comm.Parameters.Add(para);
SqlDataReader reade = comm.ExecuteReader();
while (reade.Read())
{
Session["Add"] = Convert.ToString(reade["Add"]);
}
//Button Add = (Button)PreviousPage.FindControl("Button2");
if (Session["Add"].ToString() == "Y")
{
Button2.Visible = true;
}
else
{
Button2.Visible = false;
}
con.Close();
} //con.Open
Member 10578683
17-Apr-14 8:07am
View
Thanks.
Member 10578683
17-Apr-14 7:57am
View
Button2.Visible = (Session["Add"].Equals("Y", StringComparison.InvariantCultureIgnoreCase));
thi line showing error
Member 10578683
17-Apr-14 2:41am
View
I have view edit delete checkboxes inside gridview. when i check the checkboxes.when checkboxes are checked in database y is stored otherwise N. the gridview contains a field pages that contains aspx pages. when the view checkbox is checked then only i want to view the web pages otherwise invisible
Member 10578683
17-Apr-14 2:36am
View
I am doing all these things 1st time so basic things i am not able to understand please help
Member 10578683
17-Apr-14 2:27am
View
can u give some example of it
Member 10578683
17-Apr-14 2:12am
View
that is i am asking how will i check
Member 10578683
16-Apr-14 7:08am
View
i wrote like inside button click
if(!Ispoastback)
{
populategridview();
}
then it is coming but when i am closing this page and again opens it disappears
Member 10578683
16-Apr-14 6:01am
View
i tried like this still it is not coming
Member 10578683
16-Apr-14 5:06am
View
i have not written anything in GridView1_SelcectedIndexChanged event
Member 10578683
16-Apr-14 5:02am
View
nothing
Member 10578683
15-Apr-14 4:22am
View
hi this is my code. i want to show my checkboxes remain checked whatever i have checked after button7 click
Member 10578683
15-Apr-14 4:20am
View
public partial class _Default : System.Web.UI.Page
{
DataUtility dut = new DataUtility();
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["Con"]);
protected void Page_Load(object sender, EventArgs e)
{
Label5.Text = (string)Session["Role_Name"];
if (!IsPostBack)
{
populateGridview();
}
}
public void populateGridview()
{
if (Session["Role_Name"] != null && !string.IsNullOrEmpty(Session["Role_Name"].ToString()))
{
string qry = "select ID,Pages,[Add],[View],Edit,[Delete] from Role1 where Role_Name= '" + Session["Role_Name"].ToString() + "'";
DataSet ds = dut.GetDataSet(qry);
GridView1.DataSource = ds;
GridView1.DataBind();
}
//string qry = "select Pages,[Add],[View],Edit,[Delete] from Role1 where Role_Name= '"+Label5.Text+"'";
//DataSet ds = dut.GetDataSet(qry);
//GridView1.DataSource = ds;
//GridView1.DataBind();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void Button7_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
if (Session["Role_Name"] != null && !string.IsNullOrEmpty(Session["Role_Name"].ToString()))
{
CheckBox chkAdd = (row.Cells[2].FindControl("CheckBox1") as CheckBox);
CheckBox chkEdit = (row.Cells[3].FindControl("CheckBox2") as CheckBox);
CheckBox chkView = (row.Cells[4].FindControl("CheckBox3") as CheckBox);
CheckBox chkDelete = (row.Cells[5].FindControl("CheckBox4") as CheckBox);
// string strID = row.Cells[0].Text;
string ID = row.Cells[0].Text;
string Pages = row.Cells[1].Text;
con.Open();
string query = "Update Role1 set [Add]='" + (chkAdd.Checked == true ? 'Y' : 'N') + "', [View]='" + (chkView.Checked == true ? 'Y' : 'N') + "' ,[Edit]='" + (chkEdit.Checked == true ? 'Y' : 'N') + "' ,[Delete]='" + (chkDelete.Checked == true ? 'Y' : 'N') + "' where Pages ='" + Pages + "' and Role_Name='" + Session["Role_Name"].ToString() + "'and ID='" + ID + "'";
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
con.Close();
}
}
}
populateGridview();
GridView1.DataBind();
}
}
Member 10578683
15-Apr-14 4:20am
View
populateGridview();
Member 10578683
14-Apr-14 5:10am
View
i have posted my code above. how will i do in that
Member 10578683
14-Apr-14 5:02am
View
i did like this but checkboxes are not checked. my code is
protected void Button7_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
if (Session["Role_Name"] != null && !string.IsNullOrEmpty(Session["Role_Name"].ToString()))
{
CheckBox chkAdd = (row.Cells[2].FindControl("CheckBox1") as CheckBox);
CheckBox chkEdit = (row.Cells[3].FindControl("CheckBox2") as CheckBox);
CheckBox chkView = (row.Cells[4].FindControl("CheckBox3") as CheckBox);
CheckBox chkDelete = (row.Cells[5].FindControl("CheckBox4") as CheckBox);
// string strID = row.Cells[0].Text;
string ID = row.Cells[0].Text;
string Pages = row.Cells[1].Text;
con.Open();
string query = "Update Role1 set [Add]='" + (chkAdd.Checked == true ? 'Y' : 'N') + "', [View]='" + (chkView.Checked == true ? 'Y' : 'N') + "' ,[Edit]='" + (chkEdit.Checked == true ? 'Y' : 'N') + "' ,[Delete]='" + (chkDelete.Checked == true ? 'Y' : 'N') + "' where Pages ='" + Pages + "' and Role_Name='" + Session["Role_Name"].ToString() + "'and ID='"+ID+"'";
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
populateGridview();
con.Close();
GridView1.DataBind();
}
}
}
}
Member 10578683
14-Apr-14 3:06am
View
Actually when i clicks the save button whatever i checked disappears means after a postback the checkboxes are unchecking i want to see the checkboes remain checked according to the database value
Member 10578683
14-Apr-14 2:46am
View
It is coming now .Thanks. But how my checkboxes remain checked when i close the page and again open
Member 10578683
14-Apr-14 2:43am
View
It is coming now but how my checkboxes remain checked when i close my page and again open
Member 10578683
14-Apr-14 2:39am
View
It is showing checked = false
Member 10578683
14-Apr-14 2:38am
View
i checked by putting a break point but it is showing there N value
Member 10578683
14-Apr-14 2:01am
View
i did like this.now it is coming. but when i checked my checkboes only N is updating in my database.
protected void Button7_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
if (Session["Role_Name"] != null && !string.IsNullOrEmpty(Session["Role_Name"].ToString()))
{
CheckBox chkAdd = (row.Cells[1].FindControl("CheckBox1") as CheckBox);
CheckBox chkEdit = (row.Cells[2].FindControl("CheckBox2") as CheckBox);
CheckBox chkView = (row.Cells[3].FindControl("CheckBox3") as CheckBox);
CheckBox chkDelete = (row.Cells[4].FindControl("CheckBox4") as CheckBox);
// string strID = row.Cells[0].Text;
string Pages = row.Cells[0].Text;
con.Open();
string query = "Update Role1 set [Add]='" + (chkAdd.Checked == true ? 'Y' : 'N') + "', [View]='" + (chkView.Checked == true ? 'y' : 'N') + "' ,[Edit]='" + (chkEdit.Checked == true ? 'y' : 'N') + "' ,[Delete]='" + (chkDelete.Checked == true ? 'y' : 'N') + "' where Pages ='" + Pages + "' and Role_Name='" + Session["Role_Name"].ToString() + "'";
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
populateGridview();
con.Close();
}
}
}
}
Member 10578683
8-Apr-14 7:20am
View
Thank You Very Much
Member 10578683
8-Apr-14 7:16am
View
Hi
Can you give me some good links for grid view events. So that i can understand everything about gridview.
Member 10578683
8-Apr-14 7:00am
View
When i directly take If(gdvProducts.Rows.Count>0) then it came. Thanks for the help
Member 10578683
8-Apr-14 6:59am
View
Thanks. It is working now
Member 10578683
8-Apr-14 6:48am
View
int TotalRecord = gdvProducts.Rows.Count;
if (TotalRecord > 0)
{
TextBox1.Text = "Open";
}
else
{
TextBox1.Text = "closed";
}
I wrote like this but every time it is showing closed
Member 10578683
8-Apr-14 5:16am
View
but how will i check
if(gridview1.Visible== true)
{
TextBox.Text="open"
} like this or what
Member 10578683
8-Apr-14 4:47am
View
using two queries
Member 10578683
8-Apr-14 4:43am
View
otherwise open
Member 10578683
8-Apr-14 4:43am
View
if all are repaired then 1sr gridview will not appear only second gridview wil appear .
in this case the textbox will show close
Member 10578683
8-Apr-14 4:42am
View
I have to show two grid view. If any value is present in 1st gridview then it should show open otherwise close
Member 10578683
8-Apr-14 4:40am
View
1st gridview
Member 10578683
8-Apr-14 4:12am
View
Thanks
Member 10578683
8-Apr-14 4:10am
View
Thanks to both of you. It is working.
Member 10578683
7-Apr-14 5:37am
View
now it is working.Thanks all for helping me
Member 10578683
7-Apr-14 5:23am
View
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'ID'. error is coming. if i select only product
Member 10578683
7-Apr-14 5:22am
View
I did like this but an error is coming
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'ID'.
Member 10578683
7-Apr-14 4:04am
View
I have an gridview with two columns ID Product. and a Products database. These are the data of database. I want to populate only distinct product value in gridview.
2 Mouse
3 SMPS
4 Motherboard
5 RAM
6 HDD
7 Processor
8 Monitor (TFT)
9 Mouse Pad
11 Laptop Screen
12 Monitor (CRT)
14 joystick
15 Baterry
21 RAM
22 RAM
NULL NULL
Member 10578683
7-Apr-14 3:44am
View
As in my gridview i have used both ID and Product. How will i use distinct keyword to get distinct product
Member 10578683
7-Apr-14 3:27am
View
I have two fields ID and Product. I wrote the code Select distinct ID, Product from Products but still it is not working
Member 10578683
7-Apr-14 3:21am
View
here distinct keyword is not working
Member 10578683
7-Apr-14 3:21am
View
string qry = "select distinct * from Products";
DataSet ds = du.GetDataSet(qry);
gdvProducts.DataSource = ds;
gdvProducts.DataBind();
Member 10578683
4-Apr-14 4:49am
View
Can u give some link of example to understand this
Member 10578683
2-Apr-14 7:23am
View
PlaceHolder1.Controls.Add(new LiteralControl("<input id='txt' name='Textbox" + i + "'type='text' />"));
PlaceHolder1.Controls.Add(new LiteralControl("
"));
This code generating Textboxes. My problem is how to see the prevous textboes before postback.
Member 10578683
2-Apr-14 7:11am
View
Query I have Written to get One value
Member 10578683
2-Apr-14 7:09am
View
I have already written for adding text boxes
Member 10578683
2-Apr-14 7:07am
View
But whast will i write Yaar to get exact value
Member 10578683
2-Apr-14 7:03am
View
When I am clicking the button of 1st row in my gridview in the seesion last row's vendor_Name is Appearing
Member 10578683
2-Apr-14 7:01am
View
Session shows the last value
Member 10578683
2-Apr-14 6:37am
View
ya iit is showing last value
Member 10578683
1-Apr-14 2:54am
View
It shows i value0 and strID value NULL
Member 10578683
1-Apr-14 2:53am
View
It store only the 1st value
Member 10578683
1-Apr-14 2:49am
View
I t is showing param value Null
Member 10578683
31-Mar-14 3:20am
View
no values are not coming correctly
Member 10578683
28-Mar-14 2:42am
View
I have a nested grid view. how will i store the nested gridview's value in database.
Member 10578683
27-Mar-14 3:52am
View
I have done a Role Page. In which I have written code for create a role and add the new role in to database. I have an gridview which contains the Role_ID,Role_Name,Description,Edit button.i had done another gridview which contains 6 columns such as ID,Pages,Add,View,Edit,Delete column.Pages contains different aspx page names that i have in my application. Add, View,Edit,Delete columns contains the checkboxes. I have a database for permission which also contains 6 columns that are present in the gridview.My problem is how the corresponding role's permission gridview will open when i click the edit button of the 1st gridview.
Member 10578683
27-Mar-14 1:13am
View
Do you help me if i ask my question in detail
Member 10578683
26-Mar-14 7:12am
View
if u don't want to help then its ok but don't make joke of me.
Member 10578683
26-Mar-14 4:10am
View
example of creating roles and how to assign different permission to different role and how to map with different aspx pages .can you give some clear idea
Member 10578683
26-Mar-14 4:00am
View
can you give some example so that i can understand these concepts clearly. i search through internet but unable to get these things clearly
Member 10578683
26-Mar-14 2:38am
View
Hi Dinesh,
Instead of inserting when i wrote code for update it comes.but my problem is if i select user role then only that role's permission is storing in database and checkboxes are also unchecking when i am clicking the save button.kindly help
Member 10578683
25-Mar-14 10:00am
View
I made the Role_Id to varchar but problem is when i am checking the text boxes and click the save button each time 8 rows are inserting.I had 8 row.I select a role from drom down list and click on save button. Now i have 16rows in my database and gridview. how will 1 get only one roles gridview a time
Member 10578683
25-Mar-14 9:20am
View
or without mapping with Role_Id i have to map with Role_Name. Is it Possible if i will map with Role_Name.Kindly suggest.
Member 10578683
25-Mar-14 9:14am
View
Cannot insert explicit value for identity column in table 'Role1' when IDENTITY_INSERT is set to OFF. this error is coming.by the way i have used datatype of Role_Id is int but the drop downlist contains strings. how it will be done.
Member 10578683
25-Mar-14 7:13am
View
how the roles i am selecting will be associate with my gridview. Checkboxes are also not maintaining their state. I tried with using session and viewstate but failed to do that. Hope you will help me
Member 10578683
25-Mar-14 7:10am
View
public partial class _Default : System.Web.UI.Page
{
DataUtility dut = new DataUtility();
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["Con"]);
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!Page.IsPostBack)
{
BindGrid();
}
}
catch (Exception ex)
{
}
//
}
protected void Button2_Click(object sender, EventArgs e)
{
DropDownList1.Items.Remove(DropDownList1.SelectedItem);
con.Open();
string query = "Delete from Role2 Where Role_Name <> 'Administrator' ";
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
con.Close();
}
protected void Button1_Click1(object sender, EventArgs e)
{
string fruit = TextBox1.Text.Trim();
if (!string.IsNullOrEmpty(fruit))
{
DropDownList1.Items.Add(new ListItem(fruit, fruit));
}
string role = TextBox1.Text;
con.Open();
string str = "insert into [Role2] (Role_Name) values(@Role_Name)";
using (SqlCommand insertuser = new SqlCommand(str, con))
try
{
insertuser.Parameters.AddWithValue("@Role_Name", TextBox1.Text);
insertuser.ExecuteNonQuery();
}
catch (Exception ex)
{
}
con.Close();
}
private void BindGrid()
{
string qry = "select distinct * from Role1";
DataSet ds = dut.GetDataSet(qry);
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void Button3_Click(object sender, EventArgs e)
{
//for (int i = 0; i < GridView1.Rows.Count; i++)
//{
// CheckBox chk = (CheckBox)GridView1.Rows[i].Cells[2].FindControl("CheckBox1");
// if (chk != null)
// {
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
CheckBox chkRow = (row.Cells[2].FindControl("CheckBox1") as CheckBox);
if (chkRow.Checked)
{
string strID = row.Cells[0].Text;
string Pages = row.Cells[1].Text;
string status = "Y";
con.Open();
string query = "Update Role1 set [Add] ='" + status + "' where ID= '" + strID + "' and Pages= '" + Pages + "'";
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
BindGrid();
con.Close();
}
else
{
string strID = row.Cells[0].Text;
string Pages = row.Cells[1].Text;
string status = "N";
//cmd = new SqlCommand("insert into Role1(Checkin_Add) values(" + status + " where ID= '" + strID + "' and Role_Name='" + strName + "')", con);
string query = "Update Role1 set [Add] ='" + status + "' where ID= '" + strID + "' and Pages= '" + Pages + "'";
SqlCommand cmd = new SqlCommand(query, con);
con.Open();
cmd.ExecuteNonQuery();
BindGrid();
con.Close();
}
CheckBox chk = (row.Cells[2].FindControl("CheckBox2") as CheckBox);
if (chk.Checked)
{
string strID = row.Cells[0].Text;
string Pages = row.Cells[1].Text;
Member 10578683
25-Mar-14 7:09am
View
ya understood your point but i am not able to see the checkboxes checked . i an writing my code please check it.
Member 10578683
25-Mar-14 6:05am
View
how can you give some example i am not able to understand
Member 10578683
25-Mar-14 5:22am
View
hi i made foreign key but how will i map provide permissions to the roles
Member 10578683
25-Mar-14 3:50am
View
permission table has 6 columns. ID,Pages,Add,View,Edit,Delete etc. I am trying like that u said. thanks.
Member 10578683
25-Mar-14 3:19am
View
ok
Member 10578683
24-Mar-14 9:22am
View
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!Page.IsPostBack)
{
BindGrid();
}
}
catch (Exception ex)
{
}
//
}
protected void Button2_Click(object sender, EventArgs e)
{
DropDownList1.Items.Remove(DropDownList1.SelectedItem);
con.Open();
string query = "Delete from Role2 Where Role_Name <> 'Administrator' ";
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
con.Close();
}
protected void Button1_Click1(object sender, EventArgs e)
{
string fruit = TextBox1.Text.Trim();
if (!string.IsNullOrEmpty(fruit))
{
DropDownList1.Items.Add(new ListItem(fruit, fruit));
}
string role = TextBox1.Text;
con.Open();
string str = "insert into [Role2] (Role_Name) values(@Role_Name)";
using (SqlCommand insertuser = new SqlCommand(str, con))
try
{
insertuser.Parameters.AddWithValue("@Role_Name", TextBox1.Text);
insertuser.ExecuteNonQuery();
}
catch (Exception ex)
{
}
con.Close();
}
private void BindGrid()
{
string qry = "select distinct * from Role1";
DataSet ds = dut.GetDataSet(qry);
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void Button3_Click(object sender, EventArgs e)
{
//for (int i = 0; i < GridView1.Rows.Count; i++)
//{
// CheckBox chk = (CheckBox)GridView1.Rows[i].Cells[2].FindControl("CheckBox1");
// if (chk != null)
// {
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
CheckBox chkRow = (row.Cells[2].FindControl("CheckBox1") as CheckBox);
if (chkRow.Checked)
{
string strID = row.Cells[0].Text;
string Pages = row.Cells[1].Text;
string status = "Y";
con.Open();
string query = "Update Role1 set [Add] ='" + status + "' where ID= '" + strID + "' and Pages= '" + Pages + "'";
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
BindGrid();
con.Close();
}
else
{
string strID = row.Cells[0].Text;
string Pages = row.Cells[1].Text;
string status = "N";
//cmd = new SqlCommand("insert into Role1(Checkin_Add) values(" + status + " where ID= '" + strID + "' and Role_Name='" + strName + "')", con);
string query = "Update Role1 set [Add] ='" + status + "' where ID= '" + strID + "' and Pages= '" + Pages + "'";
SqlCommand cmd = new SqlCommand(query, con);
con.Open();
cmd.ExecuteNonQuery();
BindGrid();
con.Close();
}
}
}
}
}
This is my whole code please check.
Member 10578683
24-Mar-14 9:14am
View
but when i am clicking the save button it gets unchecked
Member 10578683
24-Mar-14 9:07am
View
i want it remain checked when i m clicking the save button
Member 10578683
24-Mar-14 8:06am
View
whatever i checked after clicking the check button i want to c it checked. but it is automatically unchecked
Member 10578683
14-Mar-14 5:40am
View
ya i did like this
it is executing
Member 10578683
14-Mar-14 5:40am
View
It is now executing. but the if part is not executing
Member 10578683
14-Mar-14 5:34am
View
i have taken the column name Add in Role1 database
Member 10578683
14-Mar-14 5:33am
View
Incorrect syntax near the keyword 'Add'.
Member 10578683
14-Mar-14 5:32am
View
In else part i m getting error near cmd.ExecuteNonQuery
Member 10578683
10-Mar-14 9:50am
View
when i m going from one page to other checkboxes are not in checked format
Member 10578683
10-Mar-14 7:30am
View
this is my code for delete
Member 10578683
10-Mar-14 7:29am
View
protected void Button2_Click(object sender, EventArgs e)
{
DropDownList1.Items.Remove(DropDownList1.SelectedItem);
con.Open();
string query = "Delete from Role1 Where Role_Name <> 'Administrator' ";
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
con.Close();
}
Member 10578683
10-Mar-14 5:22am
View
i have a delete button. I wrote code for delete in the click event of the button. but out of the list of items in my drop downlist i don't want to delete Admin item.how will i do
Member 10578683
10-Mar-14 5:19am
View
hi this my code what will i do
Member 10578683
10-Mar-14 5:19am
View
protected void Button3_Click(object sender, EventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chk = (CheckBox)GridView1.Rows[i].Cells[2].FindControl("CheckBox1");
if (chk != null)
{
if (chk.Checked)
{
string strID = GridView1.Rows[i].Cells[0].Text;
string strName = GridView1.Rows[i].Cells[1].Text;
string status = "Y";
SqlCommand cmd = new SqlCommand();
cmd = new SqlCommand("Update Role1 set Checkin_Add ='" + status + "' where ID= '" + strID + "' and Role_Name= '" + strName + "'", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
else
{
string strID = GridView1.Rows[i].Cells[0].Text;
string strName = GridView1.Rows[i].Cells[1].Text;
string status = "N";
SqlCommand cmd = new SqlCommand();
//cmd = new SqlCommand("insert into Role1(Checkin_Add) values(" + status + " where ID= '" + strID + "' and Role_Name='" + strName + "')", con);
cmd = new SqlCommand("Update Role1 set Checkin_Add ='" + status + "' where ID= '" + strID + "' and Role_Name= '" + strName + "'", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
Member 10578683
10-Mar-14 4:49am
View
i want to show the check boxes remains checked wnen i checked them in every time when i will open my website
Member 10578683
10-Mar-14 2:38am
View
The corresponding column of the role field in the database the Y value is not inserting
Member 10578683
10-Mar-14 2:07am
View
I did like this u have said. But how Y will be inserted into my database. Table Name is Role.
Member 10578683
7-Mar-14 8:36am
View
yes
Member 10578683
7-Mar-14 8:34am
View
will i take all the checkboxes in template field
Member 10578683
7-Mar-14 7:25am
View
how to map that is my problem can you give some code. i am new to this field
Member 10578683
7-Mar-14 7:18am
View
can you give some code
Member 10578683
7-Mar-14 7:17am
View
Role_Id Role_Name CheckinPage_Add CheckinPage_delete CheckinPage_View Productpage_Add,
1 Admin chkbox1 chkbox2 checkbox3 checkbox4
2 User chkbox1 chkbox2 checkbox3 checkbox4
like this
Member 10578683
7-Mar-14 6:45am
View
Actually i have done one database Role in which I have columns such as Role_Id Role_Name Customerpage_Add, CustomerPage_Delete,customerPage_Edit,Productpage_Add,Productpade_View like this for all pages in one database. so here mapping is not required.My problem is how will i assign these roles to authenticated users. Suppose i have a role Supervisor. i want that supervisor can only view permission. the how will i map or do this
Member 10578683
4-Mar-14 4:47am
View
ya i m checking right checkbox but it is showing null reference error
Member 10578683
4-Mar-14 4:34am
View
yes
Show More