 |
|
 |
Azam... u did it again!
Making things so simpler and the world a better place!
|
|
|
|
 |
|
|
 |
|
 |
Thank you azamsharp your article really helped me.. thank you very much
|
|
|
|
 |
|
 |
Thank you, Azamsharp, for the article.
|
|
|
|
 |
|
 |
Hi i want to retrieve a loginid (integer) into a session, after a drop down box can be appeared in that i will store the name (varchar) of the members in the login table but the member who loin at that time it cannot be displayed(Session member).. plz clear my daught as soon as possible..
|
|
|
|
 |
|
 |
If we have paging in the same grid then we are unable to count the no. of checked checkboxes becuase the gridview.rows collection returns the rows of currentpageindex not all.
Any Solution??
Please help, thanks
modified on Friday, June 13, 2008 7:55 AM
|
|
|
|
 |
|
 |
I am using checkboxes in the GidView: grdFiles
but the values of the check boxes are not shown as in the DB
the following code is used to populate the Gridview:
romotionTableAdapters.vw_ApplicationFilesTableAdapter adapter = new romotionTableAdapters.vw_ApplicationFilesTableAdapter();
romotion.vw_ApplicationFilesDataTable table = adapter.GetDataByApplication(ApplicationID, RoleID));
grdFiles.DataSource = table;
grdFiles.DataBind();
//table has one column with bit values for checking and unchecking checkboxes in the Gridview
Pls Help me
thanks in advance
Shomaail
|
|
|
|
 |
|
 |
Hi,
I am inserting data into database by selecting checkbox in datagrid.
But when same page is open,which checkboxes have seen seleced those should appear as checked according to specific condition.
Help me.
Thank you.
|
|
|
|
 |
|
 |
hi there, i did it but using code not javascripts
/*************************************************/
#region TODO: check/uncheck all CheckBox in GridView
protected void Create_Status_CheckBox_All_CheckedChanged(object sender, EventArgs e)
{
bool checkState=false;
if (((CheckBox)(sender)).Checked)
checkState = true;
ToggleCheckState("Create_Status_CheckBox", checkState);
}
protected void Update_Status_CheckBox_All_CheckedChanged(object sender, EventArgs e)
{
bool checkState = false;
if (((CheckBox)(sender)).Checked)
checkState = true;
ToggleCheckState("Update_Status_CheckBox", checkState);
}
protected void Delete_Status_CheckBox_All_CheckedChanged(object sender, EventArgs e)
{
bool checkState = false;
if (((CheckBox)(sender)).Checked)
checkState = true;
ToggleCheckState("Delete_Status_CheckBox", checkState);
}
private void ToggleCheckState(string CheckBoxID,bool checkState)//, GridView grid)
{
if (CheckBoxID == "")
return;
// Iterate through the Products.Rows property
try
{
foreach (GridViewRow row in FuncsGridView.Rows)
{
// Access the CheckBox
CheckBox cb = (CheckBox)row.FindControl(CheckBoxID);
if (cb != null)
cb.Checked = checkState;
}
}
catch (Exception ex)
{
return;
}
}
#endregion
/*************************************************/
and in the aspx (in gridview columns
/*****************************************************/
<asp:TemplateField HeaderText="Create" SortExpression="cb1data">
<asp:CheckBox ID="Create_Status_CheckBox" runat="server" Checked='<%# IsActive((string)(Eval("Create_Status"))) %>' />
<HeaderTemplate >
<asp:CheckBox ID="Create_Status_CheckBox_All" AutoPostBack="true" Text="|Create|" runat="server" OnCheckedChanged="Create_Status_CheckBox_All_CheckedChanged" />
</HeaderTemplate>
<HeaderStyle CssClass="from" HorizontalAlign="Left" />
<asp:TemplateField HeaderText="Update" SortExpression="cb1data">
<asp:CheckBox ID="Update_Status_CheckBox" runat="server" Checked='<%# IsActive((string)(Eval("Update_Status"))) %>' />
<HeaderTemplate >
<asp:CheckBox ID="Update_Status_CheckBox_All" AutoPostBack="true" Text="|Update|" runat="server" OnCheckedChanged="Update_Status_CheckBox_All_CheckedChanged" />
</HeaderTemplate>
<HeaderStyle CssClass="from" HorizontalAlign="Left" />
<asp:TemplateField HeaderText="Delete" SortExpression="cb1data">
<asp:CheckBox ID="Delete_Status_CheckBox" runat="server" Checked='<%# IsActive((string)(Eval("Delete_Status"))) %>' />
<HeaderTemplate >
<asp:CheckBox ID="Delete_Status_CheckBox_All" AutoPostBack="true" Text="|Delete|" runat="server" OnCheckedChanged="Delete_Status_CheckBox_All_CheckedChanged" />
</HeaderTemplate>
<HeaderStyle CssClass="from" HorizontalAlign="Left" />
/*****************************************************/
where the function IsActive is my owen function to return true or false
/****************/
public bool IsActive(string asd)
{
if (asd == "Yes")
return true;
else if (asd == null)
return false;
else
return false;
}
/****************/
and that is it, so anyone can provide javascript sol to enhance posting back ??
|
|
|
|
 |
|
 |
Hi there, thanks a lot for this great topic.
I've Q,
if I've griview like this
<img src="http://aycu22.webshots.com/image/35901/2003242605890244495_rs.jpg" />
and I want to check all in these 3 columns , so can you provide any help !! thanks in advance
|
|
|
|
 |
|
 |
Even wen I hav checked the check box it returns false.. I am pasting the code here....
Any help would be strongly appreciated.
I need it urgently guys..!!!
for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridViewRow row = GridView1.Rows[i];
bool check= ((CheckBox)row.FindControl("chkselect")).Checked;
if (check)
{
string str=GridView1.Rows[i].Cells[1].Text;
Response.Write(str);
}
}
Also the DataItemIndex is zero..
I dont know how to resolve the problem since i am a beginner in asp.net please help me out
Regards,
Namrata.
-- modified at 5:43 Thursday 11th October, 2007
|
|
|
|
 |
|
 |
Hello , this problem faced me too , if you fiend solution plz write it here.
thanks a lot.
|
|
|
|
 |
|
 |
<script language="javascript" type="text/javascript">
function SelectAllCheckboxes(spanChk)
{
var oItem = spanChk.children;
var theBox=(spanChk.type=="checkbox")?spanChk:spanChk.children.item[0];
xState=theBox.checked;
elm=theBox.form.elements;
for(i=0;i
<HeaderTemplate>
<input id="chkAll" önclick="javascript:SelectAllCheckboxes(this);" runat="server" type="checkbox" />
</HeaderTemplate>
This Code Works Fine... But i got the Error in the line below...
row.Cells[2].Text...
But i bugged all the errors and it works fine...
Thank You For this Article...!
Regards,
UmayalDevi.R
-- modified at 1:46 Saturday 27th October, 2007
|
|
|
|
 |
|
 |
Great , well done
It makes problems with me as it return false even selected.
the error was that I was bindding the gridview in each load
i put this bindding in the event if (!Page.IsPostBack){GridView1.DataBind();}
and its great.
thanks a lot.
|
|
|
|
 |
|
 |
Thank you. It really worked.
|
|
|
|
 |
|
 |
If i have two cloumn each CheckBox , how can i your javascript apply to that, and also if one check box is checked other cloumn check box have to unchanged using javascript.
Tanveer
|
|
|
|
 |
|
 |
Using your example I have been trying without success to update a particular Gridview field/cell with a value, using the button click, for all rows with checkbox selected. Is this possible?
Ken Laing
|
|
|
|
 |
|
 |
You have no idea how long I have searched for a way to do this... And as it turns out, look how simple it is... Absolutely brilliant. Thanks so much for publishing this article. You get my '5' vote for this one!
|
|
|
|
 |
|
 |
Thanks a lot azamsharp, this article is really helpful
|
|
|
|
 |
|
 |
Here is my HTML code plz check it i still got checkbox value false though i select checkbox and do debug
Thanks in advance.
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="address.aspx.vb" Inherits="WebApplication1.address" %>
<!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>Contact Address</title>
<%-- following script for close window--%>
<script lang ="ja" type ="text/javascript" >
function callclose()
{
var newwindow;
newwindow=window.close()
return true
}
</script>
<%-- following java scrpt is for check all checkboxes--%>
<script language=javascript>
function SelectAllCheckboxes(spanChk){
// Added as ASPX uses SPAN for checkbox
var oItem = spanChk.children;
var theBox= (spanChk.type=="checkbox") ?
spanChk : spanChk.children.item[0];
xState=theBox.checked;
elm=theBox.form.elements;
for(i=0;i
</head>
<body>
<form id="form1" runat="server">
<asp:LinkButton ID="lnkclose" runat="server" Style="left: 104px;
position: relative; top: 160px" OnClick ="lnkclose_click" >Close
<asp:GridView
ID="GridView1" runat="server" AutoGenerateColumns="False" Style="position: relative; top: 0px;">
<asp:TemplateField HeaderText ="Select">
<HeaderTemplate >
<input id="chkAll" önclick="javascript:SelectAllCheckboxes(this);" runat="server" type="checkbox" />
</HeaderTemplate >
<asp:CheckBox ID="chk1" Enabled =true EnableTheming =true Visible =true EnableViewState =true runat="server" />
<asp:BoundField DataField ="name" HeaderText ="Name" />
<asp:BoundField DataField ="email" HeaderText ="Email-ID" />
<asp:Button ID="btnsubmmit" runat ="server" Text ="Submmit" />
<asp:CheckBox ID="chk1" runat="server" Style="left: -62px; position: relative;
top: 96px" />
</form>
</body>
</html>
============================================
and follow is my .aspx.vb code
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Partial Public Class address
Inherits System.Web.UI.Page
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim sread As SqlDataReader
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
con = New SqlConnection("server=spick;database=address;uid=sa;pwd=sa")
con.Open()
Dim s As String
s = "select name,email from address"
cmd = New SqlCommand(s, con)
sread = cmd.ExecuteReader()
GridView1.DataSource = sread
GridView1.DataBind()
con.Close()
End Sub
Protected Sub lnkclose_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkclose.Click
lnkclose.Attributes.Add("onclick", "return callclose()")
End Sub
Protected Sub btnsubmmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsubmmit.Click
If IsPostBack = True Then
Dim str As StringBuilder = New StringBuilder()
' Select the checkboxes from the GridView control
Dim i As Integer
For i = 0 To GridView1.Rows.Count - 1 Step i + 1
Dim row As GridViewRow = GridView1.Rows(i)
Dim isChecked As Boolean = (CType(row.FindControl("chk1"), CheckBox)).Checked
If (isChecked) Then
str.Append(GridView1.Rows(i).Cells(2).Text)
End If
Next
' prints out the result
Response.Write(str.ToString())
End If
End Sub
End Class
Thnks,
Jigar Chaudhari,
Software Developer
|
|
|
|
 |
|
|
 |
|
 |
Check out the following article:
http://gridviewguy.com/ArticleDetails.aspx?articleID=228
Mohammad Azam
azamsharp@gmail.com
www.gridviewguy.com
videos.gridviewguy.com
Houston, TEXAS
|
|
|
|
 |
|
 |
Thank you for your Response.
I alrady solve my problem with one of other blogger help and your article use.
thanks a lots .
Jigar Chaudhari,
Software Developer.
hi
|
|
|
|
 |
|
 |
Hey jigar let me know how did you solve your problem..
Even I am facing the same hurdle..
Regards,
Namrata
|
|
|
|
 |
|
 |
Thank you vary much.
I alrady solve problem with one of another blogger vijay modi and your article helps.
I also visited your site ,really such a helpful idea given by you.
Thanks a lots,
hi
Jigar Chaudhari
Software Devloper,
Ahmedabad-India
|
|
|
|
 |