|
Hi All,
when i am query from the data base i am getting Date in the following format
01-01-2010
but i want to display it in 01 - jan - 2010
how to this can any one help me.
Thanks and regards,
Amit Patel
|
|
|
|
|
For asp.net use <datetime>.ToString() with the suitable formatter from here .
And for MS SQL use Convert() function like here.
|
|
|
|
|
Hello,
when i change the quantity value and press update cart buttonn no chages happens and the cart quantities returns to 1 to all!!!
Here's th gridview
http://img15.imageshack.us/img15/2219/cartd.png
The Update Cart Event Handler and related methods
protected void UpdateCartButton_Click(object sender, EventArgs e)
{
System.Data.DataTable objDT = new System.Data.DataTable();
objDT = ((System.Data.DataTable)Session["Cart"]).Clone();
for (int i = 0; i <= ShoppingCartGridView.Rows.Count - 1; i++)
{
System.Data.DataRow drow = objDT.NewRow();
GridViewRow grow = ShoppingCartGridView.Rows[i];
string TempQ = ((TextBox)grow.FindControl("txtQuantity")).Text;
UpdateCartQuantities(i,TempQ);
BindTheGrid(ShoppingCartGridView);
}
}
public void UpdateCartQuantities(int rowIndex, string TempQ)
{
System.Data.DataTable CartTableForView =
(System.Data.DataTable)Session["cart"];
CartTableForView.Rows[rowIndex]["Quantity"] = TempQ;
Session["Cart"] = CartTableForView;
}
public void BindTheGrid(GridView TempGrid)
{
System.Data.DataTable CartTableForView = (System.Data.DataTable)Session["cart"];
TempGrid.DataSource = CartTableForView;
TempGrid.DataBind();
}
|
|
|
|
|
I am following http://msdn.microsoft.com/en-us/library/ms998360.aspx link to authenticate users against "actives directories" and i could successfully login using this method.
Can anyone help me out how exactly can i get details of all the users displayed in my web site application when i am logged in as Administrator.
I want to display user details when the user i.e.,Administrator clicks on link say "User Details"
|
|
|
|
|
Hi Guys,
I have a check box in my datagrid named chkSelection, also I have a bound column named phone_num
in the same datagrid. The issue is, I would like to get all the phone numbers
where a checkbox is checked...I have tried lots but can't get it right...
Anyone who knows such stuff? please help
Here is what I have tried but it won't work..
CheckBox chkSelection;
foreach (DataGridItem item in contacts.Items)
{
chkSelection = (CheckBox)item.FindControl("chkSelection");
if (chkSelection.Checked == true)
{
}
}
Thanks,
Mo
|
|
|
|
|
Are you able to find your checkbox using FindControl?
Try to quickwatch for DataGridItem to see is there checkbox available or not.
|
|
|
|
|
|
Thanks man, I tried to work through you article but
they are working on a gridview and it's not quiet the
same with a datagrid, for instance this line:
chkBoxIndex = (string)grdView.DataKeys[row.RowIndex].Value.ToString();
in a datagrid there is no [row.RowIndex]
and this is what is used to add all the row indexs to the arraylist.
do know anything relating to a datagrid in particular?
I appreciate your help man
|
|
|
|
|
The code seems ok to me, what problem are you facing?
Are you getting any error?
|
|
|
|
|
Hi friend,
No the code does not give any trouble, just now I tried this:
foreach (DataGridItem item in contacts.Items)
{
chkSelection = (CheckBox)item.FindControl("chkSelection");
if (chkSelection.Checked)
{
string contact = contacts.Items[0].Cells[4].Text;
errors.Text = contact.ToString();
errors.Visible = true;
}
}
But I want to get all phone numbers if checked, so i tried to replace:
Items[0].Cells[4] with
Items[item].Cells[4] and
it gives an error it can't convert
Items[item] to Items[int]
do you know I can manager to get all the phone numbers...
please help if you can
|
|
|
|
|
Hey u can again use the Findcontrol method in order to retrieve contact no
foreach (DataGridItem item in contacts.Items)
{
int i=0;
chkSelection = (CheckBox)item.FindControl("chkSelection");
if (chkSelection.Checked)
{
string contact = Convert.ChangeType((Label)item.FindControl("lblContactNo"),Label).text;
string[] arr=new string[20];
arr[i]= contact;
i++;
}
}
I hope this will help u....
|
|
|
|
|
This will work, but you have to add a label control for your Contact No column.
I think there should be something like (item.Index) which you can use as items[item.Index].
I am not sure but there has to be something which'll give you the rowindex.
|
|
|
|
|
<blockquote class="FQ"><div class="FQA">MorgSim wrote:</div>foreach (DataGridItem item in contacts.Items){ chkSelection = (CheckBox)item.FindControl("chkSelection"); if (chkSelection.Checked) { string contact = contacts.Items[0].Cells[4].Text;//this retrieves the phone_num at Items[0].Cells[4] errors.Text = contact.ToString();//whether checked or not, not what iam expecting really. errors.Visible = true; }}</blockquote>
Here you are not using "item" anywhere.
So, better option would be to use for loop instead of foreach.
<pre>
for(int i=0;i<contacts.Items.Count;i++)
{
string contacts = contacts.Items[i].Cells[4].Text;
}
</pre>
I think this should work.
|
|
|
|
|
Hey thanks for your help...
when I do exactly like you code it works ok as it will get all the phone numbers.
But remember i only want those phone numbers where checked is true..
So i modified the code like this:
for (int i = 0; i < contacts.Items.Count; i++)
{
foreach (DataGridItem item in contacts.Items)
{
chkSelection = (CheckBox)item.FindControl("chkSelection");
if (chkSelection.Checked)
{
string cont = contacts.Items[i].Cells[4].Text;
errors.Text += cont;
errors.Visible = true;
}
else
{
errors.Text = "";
errors.Visible = true;
}
}
}
here only the last row results to true when checked
I don't know why other rows are skipped even when checked.
Can you spot anything here?
|
|
|
|
|
Good, atleast you got a headstart.
Now, i want to know, what is this errors.Text ?
and why you are doing error.Text="" ?
I think because of this it is giving problem, try removing error.Text="".
|
|
|
|
|
nagendrathecoder wrote: Now, i want to know, what is this errors.Text ?
This will just show me the numbers that have been selected, its a label..
nagendrathecoder wrote: and why you are doing error.Text="" ?
I have disabled this and,
When I check any row, all the phone numbers are retrieved instead of just one that is checked
I don't know why this is behaving this way..
|
|
|
|
|
IMO, you don't need that foreach loop.
Remove that loop, cast checkbox like this:
CheckBox chk = (CheckBox)contacts.Items[i].Cells[4].Text;
Now, see whether it is checked or not and then append it to errors.Text.
Don't include errors.Text="".
|
|
|
|
|
nagendrathecoder wrote: CheckBox chk = (CheckBox)contacts.Items[i].Cells[4].Text;
Thanks man, well
When I do that I get an error:
Cannot convert type 'string' to 'System.Web.UI.WebControls.CheckBox'
|
|
|
|
|
Yes.
You have to do :
CheckBox chk = (CheckBox)contacts.Items[i].Cells[4].FindControl("chkBox");
|
|
|
|
|
hey hey hey brother!
man you are such a star*****
Finally all is working like expected...thanks alot
for being so helpful man
wish I could send you this
thanks again...cheers
|
|
|
|
|
Glad to know that its working. Always welcome.
|
|
|
|
|
Dear All,
I have following code in PageLoad Event
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
Session["FilteredTable"] = string.Empty;
if (Page.IsPostBack)
{
try
{
bindSelectedFields();
bindReport();
}
catch (Exception ex)
{
Response.Write(ex.Message + "<br>"+ ex.StackTrace);
}
}
}
and the same I have Code in design time
<table id="tFilterButton" ><%Response.Write(hidRmvFilter.Value);%></table>
which hidRmvFilter is hidden field.
the thing is I want to empty session variable at first visit of page. but in above code I dont know what is wrong which the session gets empty at any postback. I debugged the code and checked that when it reaches
<table id="tFilterButton" ><%Response.Write(hidRmvFilter.Value);%></table>
it again goes to the first IF block (I).
any ideas why the session gets empty at each postback or I am looking to an alternative to store session variable at any postback which it should get empty only in first page visit?
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
I think the problem is in your functions
Abdul Rahman Hamidy wrote: bindSelectedFields();
bindReport();
May be the functions causing postback again.
Try to check it again.
|
|
|
|
|
Provided your bindSelectedFields() and bindReport() are correct, this should work.
But only if you're actually performing a Postback (clicked button or similar). It won't work on a first visit per session basis if your requesting the page via a GET (such as clicking a link, or navigating directly to the page in the address bar.
|
|
|
|
|
thanks for reply, Would you please give me more information bz yours is not so clear for me.
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|